24 November 2007
Caching for Wordpress
I still find it amazing that wordpress does not install wp-cache or any caching system by default. I wonder to myself how many poor sods are out there on shared hosting running wordpress without any help. Don’t get me wrong, wordpress is nice, but its extremely heavy. WP-cache isn’t the answer either, but let’s look at the problem and solutions, shall we?
If you were to install a base wordpress install on your home machine today, and then hit the hell out of it with a load tester, you would quickly find out why so many sites suffer from the ‘digg’ effect after only 20 diggs. It’s sad, but even that paltry amount of traffic is enough to take down a base wordpress install.
Give it a try. I just did. On my laptop, running wordpress straight up and cranking on it with Apache JMeter shows a whopping throughput of about… 1 per second. Blame the laptop all you want, but think about how limited of resources you have on a shared hosting solution.
Now install WP-cache. Hey, that looks better. Big improvement with a couple clicks. But what does WP-cache actually do? It caches pages in your blog statically, but still allows for certain sections to be dynamic. It still needs to process some PHP. From the WP-cache2 page, on asking whether users actually needed WP-cache: “Probably not, WordPress is fast enough that caching usually only adds a few milliseconds of performance that isn’t really perceptible by users.”
I just cannot fathom how this could be the case under any sort of load, or even a single user hitting the page. True, not all of us need to scale that heavily, but every little bit does count. This site is (currently, until need demands it) running on a shared host, along with many of my other sites, so anything I can save off DB access and php processing is not only making this site faster, but all my other sites. Waste not, want not.
But, I have found something that works even better. WP-Super-cache seems to be quite good. It works by serving completely static pages to those users that are not logged in, and not left a comment, which is likely to be 99% of your traffic. For those remaining few, it does use normal WP-cache to serve up the page. It has a couple other nice features like a ‘lock down’ where it will always serve from the static cache, even if new comments are posted, etc, it will alway serve from the cache. The cached pages are served directly from a mod_rewrite rule, so PHP never enters the picture. Yes, this will mean that ‘most commented’ and ‘most viewed’ widgets will not update as fast, but that is perfectly acceptable, and, rather desired. Going to the database on each pageload just to update such things is a pure waste.
Anyway, give it a shot. I’m still waiting for that time where this server has to undergo some heavy load, but I’ve been dugg on 2 of my other sites recently, and, while they both eventually went down, they survived amiably for 20k+ hits in a short period of time on cheap shared hosting before crapping out (non WP sites), so we will see how well this all works.


Interesting article.
You need to fix your link to WP Super Cache. Doesn’t work.