Six ways to speed up WordPress

Introduction

Recently I have noticed that one of my sites,  A Taste of Garlic seemed to be loading slower than before.

I determined to do something about speeding it up.

Starting with some of the hints and tips found on Computing Unleashed I had a delve around to see what I could do.

Normally I connect to the internet via a caching proxy server – for the purposes of this experiment I configured Chrome to connect direct.

To measure any changes in website performance I used the excellent tools at http://tools.pingdom.com




The Starting Point

These are the results of the first Pingdom.com test. At this point I don’t know where the problem is but I do know that a site load time of 4.7 seconds is way too long!

A Taste of Garlic is a Wordpress based site and runs on a leased server at 1and1.fr

The server runs the following… Apache/2.2.9 (Debian) DAV/2 SVN/1.5.1 PHP/5.2.6-1+lenny9 with Suhosin-Patch mod_ssl/2.2.9 OpenSSL/0.9.8g mod_perl/2.0.4 Perl/v5.10.0

Step One: Reduce PHP Queries

I started off by opening every one of the PHP files that go to make up the site in a text editor and hard coding the file locations rather than using the normal PHP database queries.

This example (404.php) shows what I did…

<img src="<?php bloginfo('template_directory'); ?>/images/header.jpg" alt="Taste of Garlic" width="650" height="170" />

gets changed to…

<img src="http://www.atasteofgarlic.com/wp-content/themes/mediterranean/images/header.jpg" alt="Taste of Garlic" width="650" height="170" />

I did this for all the PHP files; basically just trying to remove every PHP database query for anything that could be hardcoded.

To find out the static locations that I used to replace to PHP lookups, I just loaded the PHP file in Chrome and then viewed the source.

I then tested the site load speed…..

The load time had decreased slightly (by 0.7 seconds) which represents a 15% increase in speed.

A good start but I get the feeling that there are many more issues to be looked at.

Step Two: Remove Redundant Plugins

I decided to remove All in one SEO Pack, SEO Friendly Images and Sociable.

This left just Askimet, Feedburner Feedsmith and Google XML Sitemaps.

Another test  and the result was. even better.

I had no idea that the plugins had so much effect.

As well as deactivating the plugins, I made a point of deleting the directories as well.

Step Three: Database Maintenance

The next step was to try and tidy up the back-end database that hadn’t had much attention since the site was launched about 9 months ago.

I started off by pruning old revisions from the Wordpress database.

To start with wp_posts had 3653 rows.

I ran (in phpMyAdmin) the following phrase….

DELETE FROM wp_posts WHERE post_type = “revision”;

That reduced the row count by 2673 rows!

Surely it’s going to be faster to find an entry out of a table with only 980 rows (rather than the 3653 it had before?)

Then, to tidy things up, I selected (once again, in phpMyAdmin), all the tables and ran a REPAIR followed by an OPTIMISE.

Moment of truth time….

And this, I’m afraid to say, made absolutely no difference at all!

I don’t think that it was the wrong thing to do – perhaps it just doesn’t have any effect on loading the home page?

Step Four: Optimise Images

A Taste of Garlic is image heavy.

Every post will have an image of a screenshot of the site that I am reviewing.

Nothing that I could do about that.

But I could ensure that the images displayed were as small as possible.

To do this, I SSH’d into the server and went to the wp-content/uploads/2010/09 directory and ran mogrify -quality 75 *jpg

I repeated this for every directory under wp-content/uploads.

On average this reduced image size by 44% without reducing the visual quality to any noticeable amount.

A further speed increase – I’m starting to enjoy this!

Step Five: Install Caching

The next step was to install caching. I decided to use the W3 Total Cache plugin as it seemed to offer the most options.

For ages it didn’t seem to make any difference but then, all of a sudden I got some decent results.

The load time has been varying over the last few hours – I’m guessing that this must be due to visitors to Garlic and all the other sites on the server?

Step Six: A Final Tidy Up

The excellent metrics shown by http://tools.pingdom.com allowed me to see where the other bottlenecks lay.

I decided to remove Google Analytics as I never looked at the results. At the same time, I also removed some social networking and visitor counter javascript code.

There were a couple of images files that weren’t in place so I copied them over.

I reduced the number of posts on the host page to 15. I could go lower than this but the whole point of A Taste of Garlic is that it is a blog review site and the links to the blogs that I have reviewed appear in the sidebar.

Thus, until I redesign the site, the sidebar is going to stay rather long (and get longer every week.)

Conclusion

I’m happy with the speedup I’ve managed to produce so far. Certainly, the site seems faster that it was. The next step will be thinking about the 20 or so graphics that are on the main page – if there were some way of caching these into server memory, that may make a difference to load times.

I hope that you’ve found this useful. I’ve still got some more work to do and will report on the results of the next set of performance improvements in about a month or so.

Of course, if you know of anything I should be trying, please let me know.

All the best

If you liked this article, why not share it with your friends on Facebook

Reddit Digg Stumble Bookmark

One Response to “Six ways to speed up WordPress”

  1. www.kmeckstein.com » Blog Archive » Wordpress SEO Optimisation Says:

    [...] A few months ago I did some work to speed up A Taste of Garlic – I wrote about it here – Six ways to speed up Wordpress. [...]

Leave a Reply