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
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.