To Cache or Not to Cache?
If you’re running your blog from a hosted platform, such as wordpress.com, Typepad or Blogger, you probably don’t have to worry about database (and/or PHP) servers choking and bandwidth running out. For folks who run blogs on their own hosting accounts or servers, this is a possibility. Yet then again, for the average blogger bandwidth and server resources shouldn’t be an issue. Even the most inexpensive hosting account on most providers these days can give enough for most folks (some hosting providers I can point to are our very own Colorteck and one of our sponsors, Cirtex).
This only becomes a big concern when you become really popular or when you get rare DIGG or Slashdot-effect traffic spikes. Or perhaps your server is a bit low on resources, and is serving up your site slowly. To address these, you can use caching plugins. We have been using several caching plugins on some of our bigger blogs like the Blog Herald and Forever Geek. Not only are traffic levels there consistently high, sometimes we also get frontpaged on DIGG, Slashdot, Stumbleupon and other social bookmarkers.
We’ve recently switched to the latter, and so far we’re satisfied.
How caching plugins work
Basically, caching works by generating static files on your server, such that database requests are no longer required. This lightens the load on your database server, and makes loading faster, too.
According to the WP-Cache profile:
It works by caching Worpress pages and storing them in a static file for serving future requests directly from the file rather than loading and compiling the whole PHP code and then building the page from the database. WP-Cache allows to serve hundred of times more pages per second, and to reduce the response time from several tenths of seconds to less than a millisecond.
And WP-Super Cache improves on this:
[WP-Cache 2 still uses] the PHP engine to serve the cached files.
WP Super Cache gets around that. When it is installed, html files are generated and they are served without ever invoking a single line of PHP. How fast can your site serve graphic files? Thatâ€™s (almost) as fast it will be able to serve these cached files. If your site is struggling to cope with the daily number of visitors, or if your site appears on Digg.com, Slashdot or any other popular site then this plugin is for you.
Pros and Cons
Great! So caching plugins help make my site load faster AND it takes the heavy load off the server by minimizing PHP execution and database queries. However, one big disadvantage of caching is that essentially your site will be static, and any dynamic elements might not work.
Sure, everytime you publish a new post, the cache is refreshed. And everytime someone posts a comment, the cache for that particular post is refreshed. At least it’s supposed to be that way. But how about those instances when you need rotating content or images. For instance, some themes use rotating headers. And sometimes, like with several blogs in the Splashpress Network, we use rotating ads (links or images that share the same spot, supposedly alternating). Another issue is when you pull feeds from external sites, like we do. See those three boxes at the rightmost sidebar? Those are feeds pulled from some of our blogging resources.
I’m not sure if caching plugins support this, but I’m assuming they don’t, since the premise with caching is that static files are served until (1) they expire; (2) they are refreshed with new posts or comments or (3) they are manually reset.
For most folks, this is not an issue. And perhaps we can resort to measures that can help resolve these. But what I’m looking for is a plugin wherein you can define which areas of your blog to cache and which not to. Hopefully that won’t be too complicated.