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.

crash-proof-large

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

Source.

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)!


10 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments
Brannon Smith
March 10, 2011 2:30 am

My site was down, version 3.1, and I took your database optimization advice and the site came right up. Thanks for the info.

Fabrizio Van Marciano
February 7, 2011 5:05 pm

Brilliant and most resourceful post. One of my blogs recently went down due to a plugin error, its definitely worth investing the time in getting your database optimised and I’ve only just started using wp super cache.

Twitter Link Roundup (10.25 – 10.31)
November 1, 2009 9:43 pm

[…] 75 PSD to HTML Resources for Web Designers Four Different Ways of Implementing Twitter on your Site 9 Ways to Create a Crash Proof WordPress Site Export All Your Google Docs to a ZIP File Blog Promotion: 169 New Ways to Build Traffic Like a […]

Il meglio della settimana #36 | BigThink
October 31, 2009 10:08 am

[…] 9 Ways to create a crash proof WordPress site Plugin e tecniche per ridurre il carico di lavoro (RAM e CPU) del nostro blog WordPress ed evitare il crash. […]

swapna
October 27, 2009 6:34 am

Ohh Great fund as!!

aravind
October 27, 2009 6:22 am

Thanks for the tips..
Just realized I have done *nothing* really to optimize my wordpress websites.
Gotta be serious on this.
Thanks again..
.-= aravind´s last blog ..30 Cool Twitter T-shirts You Can Actually Buy =-.

Indrek
October 26, 2009 7:36 pm

Excellent post!
It actually reminded me of some actions I have to take to make my blog better.

I’m a little sceptic about caching via htaccess. That way you have to use serials/timestamps for your files if you’ve updated them and want everybody to see those updates asap.

I’ve used it on a project but as I remember it didn’t have a very big effect.
.-= Indrek´s last blog ..Transparency With CSS3 =-.

Thomas Scholz
October 26, 2009 6:48 pm

If you use …
ExpiresByType text/html "access plus 600 seconds"
… Firefox users won’t see their own comments for 600 seconds after posting. This happens sometimes (?) in IE too.
Opera is smart enough to drop the cache after sending a POST request on such a page.

I had to remove this line from my .htaccess after many complaints.
.-= Thomas Scholz´s last blog ..WordPress: Umbruch im Titel steuern =-.