WordPress Tips You Really Should Know, Part II: Speeding Up Your Blog

Posted: February 8th, 2010

Photo by Foreverdigital (Flickr)

Photo by Foreverdigital (Flickr)

This is the second part of the series on WordPress tips you really should know. The first part, backing up your WordPress, is here.

WordPress, as good as a software it is, has one definite drawback: it can be slow to load. Maybe your readers will sit and wait for pages to load on your blog but, if you can save them the extra seconds, wouldn’t they appreciate it more?

Luckily, there are ways you can speed up the page loads. Drastically as a matter of fact.

First, I’ll assume you are familiar with the following:

  • FTP software to access the WordPress files. Note that I’ll refer to FileZilla here (free to download for Mac and PC).
  • phpMyAdmin to access and manage your WordPress database.

So let’s get started!

The Need For Speed… Caching

Caching is a necessity for every WordPress user. What it is it? Well, instead of generating a page through the WordPress (and the wait), cuts to the chase and delivers just the HTML page code that is normally rendered. Therefore, your pages can load ten times faster or even more.

There is an awesome plugin, which handles just that, called W3 Total Cache. On this very blog, I’ve noticed that pages load super fast with it. So it gets a heavy endorsement from me.

To install, you will need to first set the permissions  of the /wp-content directory to 777 (see below).

Setting file permissions using FileZilla (right click, select File Permissions)

Now you can download, unzip and upload the w3-total-cache folder to the /wp-content/plugins directory and activate from the Plugins section in your WordPress admin. The configuration can be accessed under Settings > W3 Total Cache in the WordPress admin although the default settings should suffice.

Don’t forget to set the file permissions of the /wp-content directory to 755 once the plugin is installed.

Post Revisions Can Slow Things Down

WordPress has a great feature, in theory, which saves each and every revision of every post as a means of backup. The problem with it is that, each time you edit a post to add a comma or correct a misspelling, an extra copy of your entire post is saved to your database.

The majority of the WordPress database is composed of blog posts. So, for example, if you average around 4 revisions for every post, your database grows by nearly four times. After a while, it becomes a huge (and slower) database.

If you are like most and can do away with saving post revisions, then you can perform a couple hacks to turn this feature off:

In the /wp-config.php file, add to it this line of code:

define('WP_POST_REVISIONS', false);

Then, using phpMyAdmin to access your database, click on the SQL tab and  run the following command to delete the current post revisions in your database:

DELETE a,b,c
FROM wp_posts a
LEFT JOIN wp_term_relationships b ON (a.ID = b.object_id)
LEFT JOIN wp_postmeta c ON (a.ID = c.post_id)
WHERE a.post_type = 'revision';

Keep in mind that this will only delete post revisions and will not affect live posts nor post drafts.

Optimizing Your Database

Maintaining the WordPress database is, fortunately, not a task you have to be on top of. It helps, though, to give it a little care, kind of like wiping the grime off of your computer screen. It has to be done once in a while.

The best tool for that is the WP-DBManager plugin which enables you to perform optimizations on your database tables. To use,  download, unzip and upload the wp-dbmanager folder to the /wp-content/plugins directory and activate from the Plugins section in your WordPress admin.

You can then access the optimize tool from Database > Optimize DB in the admin and run it with just one click. Then once a month thereafter should do the trick.

Last One…

If you display posts on your home page and notice it loads rather slow, it helps to reduce the number of posts that show on it. You can change this setting by going to Settings > Reading and setting the number to show to a lower number. Normally the default is 10 showing but reducing it to 5 or so will speed up the loading.

* * *

Do you have any other tips to optimize the speed of your WordPress blog? Drop them off in a comment below.

More on the author, Johnny Spence
Johnny is the founder of The Freelance Rant and a freelance web programmer with 8 years in the business. Have a visit at his company Oscarrr!web or see what he's up to on Twitter.

5 Comments. Join In!