Line25

How To Clean Up & Optimize Your WordPress Install

Read the full post

WordPress is a pretty robust application that is kept up to date with regular bug fixes and security patches, but it really benefits from a bit of maintenance to keep it running fast and efficiently. Over time WordPress saves snippets of information to its database, which can become bloated with unnecessary values, thus slowing down your site and putting more stress on your server setup. In this post we’ll look at 10 ways you can give your WordPress install a spring clean to trim the fat and put everything in its place.

Backup your database

Hopefully you will already have some kind of database backup system in place. If not, your entire site is at a serious risk of being completely lost. There are lots of plugins available that not only make backups on command, but can also be set to take scheduled backups and send them to your email account. I recommend WP-DBManager for its combination of useful abilities. Before following any of the other steps in this post, make sure you have a current backup and ensure your saved backups aren’t all residing on your server.

Backup your files

The most important parts of your WordPress install are saved within your database, this includes the post content and all the options you’ve configured for your site. If you’re creating database backups you’ll have safe copies of all this information, but you should also be taking backups of the files on your server. Core WordPress files and plugins can all be re-downloaded from the web, but any images you’ve added to your posts will need backing up so they can be restored should the worst happen. Make manual backups of your wp-content > uploads directory using an FTP app, or use plugins such as WordPress Backup to Dropbox to make scheduled backups for you.

Remove unused settings from old plugins

If your site has been live for a number of years, think of all the plugins you’ve installed and since removed in that period of time. Well built plugins will clean up after themselves, but others might have left their settings as values in the options table of your database. These settings are useless if you’re not even using the plugin they’re related to, so clearing these out will shave a few kbs off your overall database size. I like to install and run the Clean Options plugin every now and again to view the list of values and remove any I know for sure aren’t in use.

Disable & delete post revisions

WordPress automatically saves multiple copies of your posts while they’re being written so they can be restored if an editing mistake is made. This can be quite handy if you’re running a multi-author blog, but for most of us it means there’s an insane number of duplicate posts bloating our databases. You can easily delete existing post revisions using plugins such as WP CleanFix and turn off the post revision feature by adding the following line to your wp-config file:

define('WP_POST_REVISIONS', false );

Delete unused Post Meta information

Every post in your database is saved with a collection of information. Such information can bloat your database with values that are no longer relevant. One such example is the Post Meta Edit Lock values which prevent a post from being altered if another author is currently working on the same post. Seeing as I’ve never used multiple authors this meant every post in my database had a series of lock values associated with it. Deleting these saved a few hundred kbs. The WP CleanFix plugin also has the ability to check and remove these options built right in.

Disable image resizing

Whenever you upload an image using the built-in media tools of WordPress it automatically generates a thumbnail, medium and large variants. If you prepare your images beforehand at the correct dimensions these images are just taking up more and more space on your server. They’re not causing any major harm and don’t slow down your website, but they will make file backups take much longer. Stop these duplicates from being created by changing the dimensions of the thumbnail, medium and large settings to 0 under Settings > Media.

Empty the spam queue

The Akismet plugin does a great job of capturing spam comments before they go live on your posts. Since we don’t see this spam we often don’t think to empty the net. Every spam comment is saved so you can make the final decision as to whether it was wrongly accused, it’s not until you actually empty the spam queue that you’re saving this extra space in your database. Head to Comments > Spam and hit the Empty Spam button to nuke all the junk in a single click.

Reduce spam by closing comments

If you’re running a fairly large site you’ll know that discussion tends to drop on posts as they get older. Usually the only comments added to posts way back in your archives are dirty spam messages, so a simple fix to avoid letting this add bloat to your database is to close comments after a number of weeks. Under Settings > Discussion check the option of Automatically close comments on articles older than X days and enter your desired time period to allow discussion on your latest posts.

Optimize your database

After deleting so much bloat and removing hundreds of unnecessary values your database will now benefit from optimization more than ever. Optimizing your database essentially defrags it and reclaims the unused space. Many of the plugins we’ve talked about so far include a Repair and Optimize feature. WP-DBManager in particular is a good choice that includes the option of scheduled optimization every month.

Check your security

After a good spring clean it makes sense to give your site’s security a quick check over. Use the WP Security Scan to check for vulnerabilities in your setup and protect yourself from common brute-force attacks with the likes of the Login Lockdown plugin.

Free web shadows pack for every subscriber

Join the mailing list to have new content delivered straight to your email inbox. Every subscriber gets a free pack of realistic web shadows.

Written by Chris Spooner

Chris Spooner is a designer who loves experimenting with new web design techniques collating creative website designs. Check out Chris' design tutorials and articles at Blog.SpoonGraphics or follow his daily findings on Twitter.

13 Comments

  1. Should I find it ironic that a post written to encourage the regular updating and maintenance of a wordpress site should reference a plugin which hasn't been updated in over 2 years? (http://wordpress.org/extend/plugins/clean-options/)

    • I considered omitting Clean Options when I noticed it is no longer updated but I don't know of any others to replace it.

      After all, the functionality that it offers doesn't really need updating. The wp-options table in WordPress has been around since day one. Maybe an interface refresh would be nice but it's a basic tool that does exactly what it's meant to.

  2. This is a great list, thanks! My old wordpress install actually got attacked and I think this was because a plugin was out of date.

    Another good plugin is Better WP security http://wordpress.org/extend/plugins/better-wp-security/
    Limits login attempts, writable directories etc

  3. Pat Fortino says:

    Thanks for informative article. I knew old plugin options would build up but didn't know how to safely get rid of them. And didn't even know about the post meta. I'll give wp clean fix a try.

  4. Asif Khan says:

    I follow almost the same plan. Just wish plugins offered to delete all settings when removing them as sometimes it can be hard to identify them.

    Anyway good advice, cheers.

  5. singh-webcoursesbkk says:

    Thank you very much for the great article, going to share it with my colleague on FB

  6. Such an informative article. I think this is a nice article. and thanks for sharing.

  7. Robert says:

    Hi Chris,

    Thanks for this tutorial. I am still curious about this problem: How often should I clean up my database?

    Does it depend on how many articles I have?

  8. Harry says:

    I have wordpress blog , this information is really good for me. Thanks for your post.

  9. One must make all such tweaking a habit. It's daunting since plugins come and go. The list of the new things one must learn never seems to end.
    I like to prioritize. This helps me foget about that which is not on my daily duties list. But I find myself often tempted to add new items to my list. I am tempted now. What weight should I assign to all maintenence steps?

  10. Fernando says:

    Great advice, I'll follow it! Thank you very much, Chris.

  11. jared says:

    We've recently spent some time optimizing the database for some of our sites and the overall site load time has improved by doing this.

Comments are now closed