I had to find out how to remove old post revisions and how to limit new revisions. A few hours ago I finished writing up a post. For some reason I had a problem with it and I ended up with about 30 revisions. By default, WordPress saves all the revisions you make to your posts and pages in the database. Every time you save a post, it is considered a revision.
Looking at the 30 revisions made me realize that this is crazy and that all these new and old saved revisions were bloating my blog and slowing it down.
I did some research on how to remove old post revisions and on how to limit new revisions. What I learned, I applied to my blog and not surprisingly the steps I implemented drastically reduced the amount of bloat in my database and it helped to speed up my blog.
Today I want to share this information and show you how to remove old post revisions as well as show you the steps to take to limit new revisions that are stored in your blog’s database. Hopefully I’ll save you a couple of hours of work and a lot of blog bloat.
How To Remove Old Post Revisions Stored In Database
First I wanted to find out how to remove the old post revisions stored in the database. After some digging around I have found several solutions. One involved changing some information in the MySQL files and I was not that courageous. I did not want to touch these files because I know that if I did something wrong I could completely screw up my blog. Even if I had a backup, I just did not want to go through the trouble.
Fortunately, I found a couple of plugins to do this task for me. One of them “Better Delete Revisions” had very good write ups but unfortunately it has not been updated for about 3 years (although people are still downloading it even today), so you may want to have a look at it anyway.
The second plugin was “Optimize DataBase After Deleting Revisions” and I chose to use it. For those who are opposed to adding more plugins to your site, it’s OK. All you do is to upload it and use it (the whole cleanup process takes less than a minute) just once, then delete it from your blog and once or twice per month re-upload it and do your clean up. That is exactly what I did.
After I used the “Optimize DataBase After Deleting Revisions” plugin, it got rid of almost 10 MB of junk from my database. You can just imagine how this cleanup really helped to speed up my blog. That’s a lot of stuff, gone! Honestly, I was quite surprised.
How to reduce or limit post revisions
I also found some answers for limiting the number of post revisions for a new post. Right now WordPress will register and save every revision you make irrespective of the numbers. Not only that, it also saves the drafts by autosaves at certain intervals. I just don’t see the reason behind having so many safe checks. It just bloats our blogs and makes them sluggish.
There are several ways you can “order” WordPress to reduce the number of revisions it keeps. The “Optimize DataBase After Deleting Revisions” plugin that I mentioned before will do it.
But if you do not want to keep the plugin you can easily do it yourself. Below I’ll show you the steps I took. I am not techie so if I could do it, you can definitely do it too.
What you need to do is add a short code to your wp.config.php file in your file manager.
The code to add is:
You can replace the number in the code for any number you are comfortable with. WordPress will keep only the last 2 (or whatever number you choose) revisions.
Some people may want to completely eliminate post revisions (although I would not recommend this). In that case replace the number with 0 and no revisions will be kept.
Step By Step Instruction To Add Code Into Your wp.config.php File
1. In File Manager (in your cpanel) locate the wp.config.php file.
2. Highlight the wp.config.php file and click on edit (see image above). Open the editor and locate @package WordPress.
3. In the editor add the code underneath */
4. In your file manager, save the edit and you are done.
In summary, using the “Optimize DataBase After Deleting Revisions” plugin temporarily to remove old post revisions cleaned up my blog significantly. It removed almost 60% of unnecessary data from my blog’s database. That is huge! This action alone significantly contributed to speeding up my blog. As well, as I am writing this post WordPress is keeping my current post revisions on 2.
Although piddling with your wp.config.php files may seem frightening, believe me if I can do it you can too. Just follow the instructions above. Also, just in case, copy the file to notepad and save it should anything go wrong (nothing will go wrong).
Previously I wrote a couple of articles on blog speed. You may want to read both of them if you have not read them yet:
- Improve The Speed Of Your Website – Leverage Browser Catching, Enable Gzip Compression ~ read here…
- How To Optimize Images To Speed Up Your Blog ~ read on…
Please leave a comment and let me know if you found this post helpful. And, please don’t forget to like and G+ this article, if you enjoyed it. Thanks.