I’ve been using Textpattern CMS for a number of years. During this time, I’ve learned a lot – whether it’s from A/B testing, digging around in the configuration settings or satisfying my curiosity with trial and error. Whenever I show Textpattern to a user or administrator, I like to share some of the things I’ve gathered over the years. With that in mind, my latest series of articles is called Ten Textpattern Tips. In this series, I’ll share ten things I’ve learned that I believe will be useful to you as an administrator or contributor of Textpattern. Please note, they are not in any particular order of importance, so please don’t treat this as a top-ten chart hit rundown that you’d hear on the radio. As always, your comments are welcome on any or all of my published tips.
Out-of-the-box, Textpattern includes a visitor log system. That is to say, if someone (a person) or something (a bot) views your Textpattern-powered site, selected details are taken from their visit and a log is updated. This log is located inside the Textpattern database. The following info is recorded:
- timestamp of their visit
- IP address
- host lookup (optional)
- the page URL
- the referrer
- the method (GET or POST)
- the http status
Now, if you’re looking at this list and you’re scratching your head as to what you can do with this information, or perhaps a bit confused about the difference between GET and POST requests, here is my advice: turn visitor logging off. If you’re using Google Analytics or another third-party tool, turn Textpattern visitor logging off. If you’re frankly not interested in any of this statistical stuff at all, turn logging off. You get the idea.
The reason behind this is the amount of stuff written to your database. Factor in the list of items scooped from each page hit, then multiply that by the number of pages a visitor looks at, and the multiply that by the number of people who visit your site. There’s a lot of text being logged in a database for potentially not much in return. Textpattern logs the hits and provides a search function to find certain things. It doesn’t have a native graphical interpretation of visitors in the style that WordPress does. If you want graphs for your visitor stats, look into a third party tool like Google Analytics or HitTail and integrate it. Or, investigate WordPress as an alternative to Textpattern.
Yes, I did say that – I haven’t lost my mind: get the right tool for your job, whether that’s Textpattern or not.
Back to visitor logs. There’s no scheduled truncating of the visitor log file in Textpattern core. The action of viewing the logs from the administration panel will perform some housekeeping and trim back the log to the time period specified from the administration tab, but if you don’t check the visitor logs for some time it won’t get trimmed. The Textpattern database will grow in size, and as the database becomes larger it will become less responsive. From an Arvixe point of view, having a well-behaved database is a good thing: just because you’re allotted a bunch of databases with a generous limit on each, doesn’t mean you have to use up your allocation. In addition, backing up your database will take less time if it’s not chock-full of visitor logs. You do back up your database(s) regularly, right?
Speaking of databases, if you have visitor logging disabled, there are fewer database queries happening. This is the output from a default front page with visitor logging enabled:
<!-- Runtime: 0.0439 --> <!-- Query time: 0.018887 --> <!-- Queries: 18 --> <!-- Memory: 4263Kb, end of textpattern() -->
…and the same page without visitor logging enabled:
<!-- Runtime: 0.0250 --> <!-- Query time: 0.004887 --> <!-- Queries: 16 --> <!-- Memory: 4263Kb, end of textpattern() -->
Two fewer queries and a shorter runtime. Excellent.
If you use visitor logs in Textpattern as they are, then you may find some value in setting the logs to only show referrers. Additionally, if you limit your log files to a small number of days (say, 3, 5 or 7) you’ll get some useful info without bloating your database. If you’re in and out of Textpattern very regularly, switch your log file retention to 1 day. Both of these options are set within the Administration -> Preferences section of the Textpattern administration area.
If you do use your Textpattern logs, make a habit of checking them regularly. If you don’t use ‘em, lose ‘em.