WordPress errors a problem? Too high of a load for your web host? Worried about getting dugg, stumbled, or slashdotted? Learn now to “traffic proof” your WordPress site or blog!

This is installment #13 in 30 WordPress Hacks in 30 Days!

If you’ve blogging for any length of time, or if you own multiple blogs at one time or another you’re likely to have a problem with “too much traffic”. In this hacks series I’ve shown you how to keep your database maintained, but that doesn’t really matter if your starting to get 20,000 unique views per day or more. I’ve found over the that’s about the tipping point for most shared web hosts, the point at which your site reaches more than 250,000 “requests” per day or more and it starts maxing out the resources alloted to your domain. Every single time someone visits your WordPress site, it makes “calls” to the database server to retrieve the posts, and the pages, and the categories, and header, and the footer, and your archives, and on and on and on. Get the picture? One page load could mean a dozen+ “calls” to the database. That’s why 20,000 “page views” could mean “250,000 requests” for your site.

I actually got an email today after dinner about one of my sites having “very high loads” on the server, and that today requests were way over 300,000 and it was the highest traffic day in a very long time with 22,000+ pageviews. I knew it was time to enable some sort of caching on this site. The WP-Cache plugin has been around awhile (4-5 years), and I’ve used it before, but the main problem I’ve always had is you have to disable everything on your site that is either interactive or counts. This would include wp-postview (page and post counts), wp-postrating (live post ratings), etc. Even comments are a slight issue, since once they are approved it can be up to an hour before they appear on the cached pages. “Normally” all javascript things, like adsense ads or affiliate ads work just fine, since they are called live on the cached pages the same as if they came from the WordPress database.

WP-Cache hasn’t been updated in a few years from what I saw on their web site, but that’s ok because “WP-Super Cache” has come along. It’s bigger and better than WP-Cache because the PHP engine is never called and it’s much quicker. Now, for those of you new to WordPress that might not be so technical – what is a “cache?” A cache is when you have common pages stored so they don’t have to be fetched from a database every time if nothing has been updated. Your web brower has a “cache” and it uses the copy of web pages on your PC if nothing has changed on the web version. The WordPress wp-super-cache plugin speeds up pages on your blog in the same way.

I happenned along a post a few weeks back on OminNoggin – “Make Popularity Contest Work with WP Super Cache“. I thought this as really cool, because he solved the problem by making the counters and statistics work using javascript instead of PHP. I asked him in the comments if he could do the same to make Lester Chan’s WP-Postviews work on Javascript counts as all and he did! Note – his fix only works on WordPress 2.5, so first I deactivated the WP-PostViews plugin, and then I upgraded to WordPress 2.5. The I installed WP-Super Cache, and last I upgraded to the JavaScript version of WP-PostViews – and everything seemed to work fine!

Let me say, “Your Mileage May Vary”! The site I upgraded (that is now working fine with WP-Supercache AND JavaScript WP-PostViews) only has about a dozen WordPress plugins. Everything seems to co-exist there just fine so far and the pages load much, much faster. I attempted to do the same install tonight here on jtpratt.com and it didn’t go so well. I did receive some 500 errors, and the homepage didn’t seem to get any post counts for the updated JavaScript WP-PostViews. This blog is quite the exception since I use almst 4 dozen plugins, and quite a few of them are interactive – like SezWho, which enhances my comments. I disabled WP-Super-Cache here and backed out all the changes it made (to my .htaccess file) and deleted all it’s cached pages and deleted the plugin. I even had to click “update” on my “Options -> Permalinks” page to get the site to act normally again. I think most “normal” sites (that don’t have all the crazy hacks I have here) will do just fine traffic proofing with WP-Super-Cache. If you use Popularity Contest or WP-PostViews use the updated plugins I linked to. If you have other problems with WP-Super-Cache and a plugin – maybe Thaya Kareeson would be kind enough to help with this as well.

As always – if you have problems, questions, or something to add – please comment now!