Speed is an important factor for both visitors and search engines, and the faster your site, the better it is. Optimise WordPress by removing post revisions and junk files to improve performance.
What is a WordPress post revision?
When a post is publish on a WordPress blog or site, it is saved in a database. If you return to the post and edit it, make some changes, then update it, the new version is published, but a copy of the old version is kept as a revision.
Every time you edit and update a post, the old one is saved as another revision. Many posts can have revisions and there can be many revisions for a post. This means that there are multiple copies of many of the pages on your website. In fact, any page you have ever edited, ever!
Advantages of WordPress revisions
The advantage of storing revisions is that you can return to a previous version of the post. For example, if you made some changes, but then decided they were not very good after all, you could restore a previous version instead of having to recreate it all over again.
Open a post in the WordPress editor and look at the Publish box in the top right corner. It tells you the number of revisions that have been stored.
To view and restore the revisions, click the Browse link.
Two revisions are shown at a time and on the right is the latest version and on the left is the previous one. The changes are highlighted in red (old version) and green (new version).
Drag the slider at the top of the page to browse the revisions and click the big blue button to restore a revision. This could be a life-saver if you have made disastrous changes to a post and want to revert to a previous one.
Disadvantages of WordPress revisions
Storing multiple copies of posts makes the database in which they are stored bigger. In extreme cases this can result in databases that are bloated and it can reduce the performance of your website. Backups also take longer to complete and they require more storage space.
As a website grows older and more posts are added and edited, it becomes more bloated with old copies of posts. What can you do?
Limit post revisions
There is a way to limit the number of revisions that WordPress stores and this can help to prevent it from becoming too bloated. However, you do need some technical knowledge and it is not for novices.
There is a file on the web server in the root (top level) called wp-config.php. In this file is a line like this:
define( 'WP_POST_REVISIONS', 5 );
If it does not exist, it can be added to the end of the file.
That number near the end of the line is the number of revisions to store and it can be changed to anything. For example, set it to 3 and only three revisions will be stored. Set it to 1 to store just the last version of the post is kept. This keeps the bloat down while still enabling you to revert to a previous version of a post if you need to.
Even just storing one revision will produce some WordPress database bloat and setting the revisions to zero eliminates them completely and this results in no bloat and the best performance.
If you have an ftp program and you know how to use it, connect to your site and download wp-config.php. Load it into a text editor like TextWrangler on the Apple Mac or Notepad on the PC and edit or add that line above. Set it to 0 for no revisions if you have never needed them.
Delete WordPress revisions and junk
There is an easier way to do this, but it requires a plugin. Click Plugins in the sidebar in WordPress and then click Add New.
Search for ‘delete revisions’.
There are several to choose from and the one with the highest rating and most installations is WP-Optimize. Install it and then activate it.
Select WP-Optimize in the sidebar to access the plugin functions and settings.
The best time to use it is just after creating a backup of your website. It is very unlikely that anything will go wrong, but a backup is recommended. The plugin is from the developers of UpdraftPlus backup plugin and there is an option to automatically make a backup before optimising WordPress.
The default settings are the best ones, so there is no need to change anything. Just click the button to optimise your site and after a minute or so, it is done.
In addition to removing revisions, WP-Optimize also deletes junk like comments sent to the trash or marked as spam.
On the Settings tab is an option to run the plugin on a schedule, such as weekly. This is useful for a top website with a team of writers constantly posting and editing articles, but it is not necessary for solo bloggers who post a couple of times a week.
How often you use it depends on how often you edit posts. Many bloggers will only need to run it every six months or even just once a year.
If you have set the number of post revisions to zero, you may not need it again.