9 Ways to Create a Crash Proof WordPress Site

As your blog starts to grow, inevitably you’ll get one big spike of traffic and your site will go down. Rubbish. This post has nine ways to combat that and create a ‘crash proof’ WordPress blog.


1. W3 Total Cache

Used here on WPShout:

Trusted by many popular blogs like: mashable.com, pearsonified.com, webdesignerdepot.com, freelanceswitch.com, davidbhayes.com, css3.info, tutsplus.com, yoast.com, noupe.com and others — W3 Total Cache improves the user experience of your blog by caching every aspect of your site, reducing the download time of your theme and providing transparent content delivery network (CDN) integration.

It’s a great caching platform that creates static versions of your pages. And a heck of a lot more!

W3 Total Cache

2. WP Super Cache

The caching plugin that everyone uses (at least until W3 Total Cache came along!). I’m no expert, but W3 Total Cache and WP Super Cache are pretty similar – they’re both caching plugins. However, to me at least, it looks as though Total Cache is a tad more superior with a couple of additional features. That said, they’re both excellent plugins and the only way to pick between them is to try them both out! So do that!

A classic method of preparing an under powered site for a Digg front page appearance or a Slashdotting has been to manually save copies of dynamically generated pages, and place them in directories that match the permalinks structure. This method of performance enhancement does help servers handle a higher load without crashing, but is only effective when an oncoming rush of traffic can be anticipated. WP-Cache alone, while helpful, is not adequate in many cases, so WP Super Cache was created to effectively mimic the manual page caching method, but to handle it in an automated fashion.

Just to prove it works, check out FrozenToothpaste.com – it’s using a standard layout of featured post and then recent posts below. With Super Cache turned on, it’s loading just over a second!

WP Super Cache

3. Caching with .htaccess!

As I wrote a while ago, it’s really easy to cache your files with the .htaccess file – the following code can just be plopped into your .htaccess file:

# BEGIN Expire headers

  ExpiresActive On
  ExpiresDefault "access plus 1 seconds"
  ExpiresByType image/x-icon "access plus 2592000 seconds"
  ExpiresByType image/jpeg "access plus 2592000 seconds"
  ExpiresByType image/png "access plus 2592000 seconds"
  ExpiresByType image/gif "access plus 2592000 seconds"
  ExpiresByType application/x-shockwave-flash "access plus 2592000 seconds"
  ExpiresByType text/css "access plus 604800 seconds"
  ExpiresByType text/javascript "access plus 216000 seconds"
  ExpiresByType application/x-javascript "access plus 216000 seconds"
  ExpiresByType text/html "access plus 600 seconds"
  ExpiresByType application/xhtml+xml "access plus 600 seconds"

# END Expire headers


4. Reduce database queries

This is a killer one. Reducing the number of database queries your theme is making can be the difference between your site staying up and going down! You can easily check how many queries your theme is using with the following:

<?php if (is_user_logged_in()) { ?>
    <?php echo get_num_queries(); ?> queries in <?php timer_stop(1); ?> seconds.
<?php } ?>

Counters are great for reducing your queries – look at Binary Moon‘s sidebar to see an example of how counters can be used to pull a load of data in a single loop.

It’s all very easy seeing how many database queries you’re making, but reducing them? That’s the interesting bit. The culprit can often be plugins – the YARPP plugin makes a heck of a lot of queries (often 10+!) and whilst it’s incredibly customisable, it could well be slowing down your site a heck of a lot. Just bear that in mind.

The next thing on the list is custom fields. WPShout is using custom fields on the homepage in order to grab a featured image. Getting rid of those images took the count down three queries so that’s something to bear in mind when creating a magazine theme.

Custom loops are a massive culprit too with even the simple downloads section on WPShout using five queries! With something like that with relatively static content, it can be an idea to comment out the query and replace with the static code generated (ie copying and pasting from the source code).

5. Utilise your .htaccess file

We’ve already touched on .htaccess in this article, but there is a heck of a lot more you can do with it – check out “10 Ways to Use .htaccess to Speed Up WordPress” for more tips – you can easily cache, gzip, stop hotlinking, the lot!

6. Take the load off your server

An interesting one this that I’ve been experimenting a bit with recently. The idea? Use a service such as Amazon S3 to host your images, CSS and JS, making your site load quicker and taking some of the load off your server.

In practice, using Amazon S3 day to day is a little more challenging. However, with a plugin such as “Amazon S3 for WordPress” it’s fairly easy to use S3 to host all of your media files.

7. Clean up that database!

As I explain in this post, it’s very easy to optimise your database – login to cPanel and then load up phpMyAdmin. Next, select the database WordPress is installed on and then ‘Check all’ checkboxes. Then on the dropdown at the bottom of the page click ‘Optimize table’ and you’re done!

8. Get a decent host!

This one’s uber important. Without a good host, a spike of traffic will see your site plummet out of the interweb. A decent host should be an integral part of your blog’s strategy. Yes, they will cost more, but you’ll not regret it when your site gets popular on Twitter and the site remains up.

9. Your thoughts

I haven’t done this for a while, so here goes. Why not suggest your way of optimising your theme. Leave a comment below (RSS readers jump to the comment form here)!