WordPress Caching Overview
You would think that over the long period since everyone used static pages for their websites, we wouldn’t have to come full circle, but with the ever increasing audience of web savvy users, database calls can bring a website to its knees.
Do huge waves of traffic have to bring your WordPress powered site down? Not if you are properly prepared.
What is Caching?
Basically, caching takes a duplicate of a page, and creates a static file from it. This means that as each new user comes to view the page, they don’t make the software, in this case WordPress, poll the database again. This reduced the strain on the server hosting your site, and makes it able to handle larger waves of traffic.
Wikipedia breaks it down really nicely:
In computer science, a cache (IPA:/kæʃ/, like “cash” ) is a collection of data duplicating original values stored elsewhere or computed earlier, where the original data is expensive to fetch (due to longer access time) or to compute, compared to the cost of reading the cache. In other words, a cache is a temporary storage area where frequently accessed data can be stored for rapid access. Once the data is stored in the cache, future use can be made by accessing the cached copy rather than re-fetching or recomputing the original data, so that the average access time is shorter. Cache, therefore, helps expedite data access that the CPU would otherwise need to fetch from main memory.
Why is it important?
They blame their hosts for this because they believe it to be their fault, when instead the hosts are really just looking out for their own business
I have seen so many people complain about how their web host shut down their site just as they got on the front page of Digg, or that the site crashed. They blame their hosts for this because they believe it to be their fault, when instead the hosts are really just looking out for their own business, and the other websites on the server that your site is on.
Most people have shared hosting, and what this means is that there are numerous websites, files, and other blogs all being run from one server, and while bandwidth and hosting is super cheap, adding additional processors (CPU’s) to the server can be very expensive and so CPU time must be limited on each account to keep the stability of all the sites as perfect as possible.
When your WordPress powered site gets a great deal of traffic in a short period of time, the processor is put under a fair deal of strain, and if you have ever opened so many applications that you have slowed or even frozen your computer, the same can happen to the server. Now imagine if there were a dozen people all working from your computer. Wouldn’t you be frustrated if it froze out everyone every time a large spreadsheet was opened?
So web hosts put in measures to stop any one site from disrupting all the sites on the single server. Really though, part of the responsibility is the owner of the site, and if you don’t plan accordingly, then you deserve any disruption of service that you get.
Are there any downsides?
Pretty much any caching plugin is going to have its limitations. A cached page may not show certain “live” details correctly, like how many people viewing a page, and this is because the page being served is not pre-processed every time by the server. This is a small consequence in comparison to keeping your site live during large waves of traffic.
WordPress Caching Plugins
There are a few WordPress plugins that will help you create cached pages of your blog, its feed, and any externally linked images you may be using. The most popular one to date has been WP-Cache 2.0. It has a great deal of respect in the WordPress community, and has been tested and proven to be beneficial during high traffic times.
Some details from the site:
WP-Cache is an extremely efficient WordPress page caching system to make your site much faster and responsive. 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.
WP-Cache started from the “Staticize Reloaded” by matt and billzeller. Most of their recommendations also apply to WP-Cache. Current version, WP-Cache2, is a huge improvement over previous versions of WP-Cache.
There are other options though, as Donncha has built Super Cache, a series of modifications to WP-Cache 2. It continues to add new features, as well as fixing some things that weren’t necessarily perfect in the last version of WP-Cache 2, and has already had a 0.2 release put out which many WordPress fans are enjoying.
One feature that stood out to me was that Super Cache will only create a new cache file for a post, if a comment is not marked as spam by Akismet. I think this is brilliant and makes complete sense, and will only serve to help continue to make WordPress blogs as efficient as possible in their performance.
Super Cache, on release, did make it to the Digg front page, but unfortunately, it didn’t attract the full on “Digg-effect”, and as such didn’t give Super Cache the initial test we were all hoping for, but Donncha’s results are still very impressive. Check it out on his blog, Ocaoimh.ie.
As for other caching tools, there is FeedCache, which will cache your RSS feeds, Cache Images, which takes images you have linked to that are not on your site and copies them to your own content folder, and there are many others depending on the task you want to compete.
Other measures you can take
Using a WordPress plugin isn’t the only thing you can do to reduce the server strain that your site creates. You can also remove some of the graphics you are currently using, to make the page’s file size smaller. One of my favorite ways to do this would be to change the print stylesheet into the default stylesheet during high traffic times. This will allow you to continue to feature your content, and images relevant to the post, but remove most other elements.
If the choice is between having a fancy design or keeping your site up, I am sure you would rather keep your site up. To accomplish this, you can create your own print stylesheet, or use a plugin like WP Print and change the header.php to use the stylesheet that comes with the plugin during high traffic loads.
Donncha also recommends a server application called Xcache.
For maximum performance, download Xcache and install it. The Xcache WordPress plugin uses Xcache to cache data structures and makes WordPress much faster, even if you don’t use any other caching tool.
To use Xcache though, you would have to have the ability to install things on your hosting server, or if you politely ask your host, maybe they will install it for you, but this is not something that most places will allow you to use. I still wanted to include it though as an option though, as I continually hear how great it is at reducing server load.
Getting to the front page of any popular website can mean huge amounts of traffic, but if you are not prepared, it will all be wasted as people are brought to an error page. I highly recommend that those using WordPress, or any software that doesn’t used static files to display content, research caching options for your sites, as you never know when you will need it.
And try to remember that it is not just your hosts fault when your site goes down due to a huge burst of traffic.