WordPress Fat-Loss Diet to Speed Up & Ease Load

September 6, 2010 No Comments »

Last week we looked at some useful plugins to enhance and protect WordPress, following on with the WordPress topic let’s look at how you can tweak your WordPress install to increase the speed of your site and ease the load on your web servers. We’ll be putting the front end code on a strict diet, while trimming the fat from the database to produce a fast, lean website that doesn’t clog up your server’s resources.

Despite its general awesomeness and wide adoption across the web as both a blogging platform and a trusty CMS, it’s no secret that WordPress is a greedy old memory hog. This high memory usage soon becomes apparent when your blog receives a decent number of visitors and your blog goes missing due to your server throwing in the towel.

Installing one of the many caching plugins fixes 90% of these server problems, while upgrading your server specs solves the rest. But it’s not all about uptime and downtime, we also want a speedy site that loads in a flash every day. Follow this 10 step exercise regime for your blog and you’ll take it from a slobbering podgy couch potato to a ripped and finely tuned pentathlon athlete.

Step One – Install a Caching plugin

Caching solves 90% of those server problems. It dramatically eases the load on your server by presenting static files to users instead of making numerous calls back and forth to the database. There’s a hand full of plugins to choose from including WP-Cache, WP Super Cache, Hyper Cache and W3 Total Cache. Check out this handy post from Tutorial9 for a more thorough overview.

My choice goes with W3 Total Cache as it combines not only page caching, but also database caching, browser caching, object caching and minify settings.

Step two – Lose the plugins & widgets

WordPress plugins are what makes the application so powerful, but there’s some that you could either remove altogether, or hard code into your theme. Each plugin creates extra processes your server will have to resolve each time a page is loaded so removing these processes can really help speed up your site.

Instead of using a plugin to insert your Analytics code into your page footer, do it yourself. Rather than rely on a plugin to insert share buttons, add them to the theme yourself. Chances are some of these plugins will be bloated with unnecessary code and will call their own CSS and Javascript files for features you might not even be using.

Step three – Hard code your templates

This one is definitely more for the designers and developers who run their own sites, as opposed to sites that need to be editable for clients, or for public themes. Swapping out the WordPress PHP tags for plain old HTML can really help increase the speed of your site as you’re essentially cutting out the extra steps WordPress has to take. Let’s take <?php wp_list_pages(); ?> for example. Each time the your webpage is loaded, WordPress has to check the database for the number of pages it has stored, then inject them into your theme as a series of <li> elements.

Instead, link up the pages directly in your theme file:

<ul>
	<li><a href="/category/articles">Articles</a></li>
	<li><a href="/category/inspiration">Inspiration</a></li>
	<li><a href="/category/tutorials">Tutorials</a></li>
	<li><a href="/about">About</a></li>
	<li><a href="/advertise">Advertise</a></li>
	<li><a href="/contact">Contact</a></li>
</ul>

The same can be done for lots of standard PHP tags in your WordPress theme, what about <?php bloginfo('name'); ?>, <?php wp_list_categories(); ?> or <?php bloginfo('stylesheet_url'); ?> Once your site is set up, chances are these elements aren’t going to change anytime soon.

Step four – Minify your HTML & CSS

Minifying can help squeeze out every last Kilobyte from your front end files, speeding up your pages by whole milliseconds. If you picked out W3 Total Cache as your caching plugin of choice, you have Minify settings right at your fingertips. Minifying strips out white space and comments from your HTML and CSS files, which lowers the filesizes and subsequently allows for faster load times.

Step five – Smush your images

Images make up a large portion of the files that are downloaded during every page load. Some files, like header images and other theme related graphics are loaded on every page so it’s worth making sure these images are as lean as they can be. Upload and replace your theme image files with versions that have been run through the Smush.it engine. For all the other images uploaded through WordPress, the WP Smush.it WordPress plugin helps optimize images as they’re used.

Step six – Disable post revisions

Post revisions are a handy feature if you’re running a multi-author blog, but for most of us it’s an unused feature of WordPress. Post revisions can seriously bloat your database with multiple copies of posts, adding extra MBs to your SQL files. To turn it off, simply add the following code to your wp-config file:

define('WP_POST_REVISIONS', false );

Don’t forget to delete existing post revisions using the following SQL query, through phpmyadmin or similar (as always, create a backup before making such changes):

DELETE FROM wp_posts WHERE post_type = "revision";

Step seven – Delete all spam comments

Just like a hoard of post revisions, spam comments that have been captured by Akismet can take up some serious database space, especially if you haven’t done a spring clean in a while and there’s thousands of comments polluting your spam section. Thankfully it’s easy to nuke them all with the swift click of a button in the WordPress admin area.

Step eight – Run a Clean Options check

If your blog is a few years old, chances are you will have installed plugins that you don’t use anymore. Most plugins are developed well and clean up after themselves when they’re uninstalled, unfortunately there are others than leave behind all their settings and information. These unused tables can bloat your database so it’s useful to purge them to free up space. The WordPress plugin Clean Options is a handy tool for giving your database a clear out. It looks for tables that are no longer in use then gives you the option of deleting them.

Step nine – Optimize your database

Over time your database develops clutter. Just like the drefragging of a hard drive, optimizing your database removes this clutter and puts everything back in its place. There’s two easy methods of doing so, with a plugin or via phpmyadmin. If you have WP-DBManager installed, this plugin has the optimize feature built in and can even schedule the job to run automatically.

Step ten – Purchase multiple servers

You may reach a point where even your trimmed WordPress install still breaks even the most finely tuned and highly specced VPS or dedicated server under high load. The next step is to not only increase your server size, but also in numbers. Using one highly specced server purely for MySQL allows the database to use as much resources as it needs, while the PHP and front end files reside on a smaller server.
Use the define('DB_HOST'); setting in the wp-config.php file to specify the IP of the server the database is living on.

Related Posts

Leave A Response