WordPress post revisions can be useful when you’re writing content. It’s what allows WordPress to auto-save drafts while you’re in the post editor so you don’t lose your work should something go wrong, like when your browser crashes. Every time you press “save draft,” a new one is created.
But over time, WordPress post revisions can add some serious overhead to your database, which can
- Make your site slow and unresponsive
- Take up needed space in your database
- Decrease your search engine rankings
Why does the time it takes my site to load matter?
The time it takes your site to load matters because visitors will decide to stick around for your awesome content based on how long it takes to get to their screens. Visitors like times around three seconds. So, for that matter, do search engines. So if your site loads slower than that, you’re losing readers.
While WordPress post revisions aren’t the only thing that can slow down your site, they are a contributing factor. they’re also one of the easiest aspects of site performance to manage.
Why does the size of my database matter?
The size of your WordPress database matters because it effects your site’s performance, and it also effects the amount of work your web host’s server has to do to casche resources, no matter what casching method you use. Also, if you’re on a smaller hosting plan, you are often limited significantly by the database size your web host will allow. Finally, the size of your database can also effect how hard it is to move your site from one web host to another, and switching hosts is something that happens throughout the lifetime of every website. On most web hosts, especially if you’re using PHPMyAdmin instead of the command line, the database size is limited to 8MB. That means if your database is bigger than that, you’re not moving it over. PHPMyAdmin does offer the option of breaking up imports into smaller pieces, but even it doesn’t recommend this. And web hosts don’t often increase the size limit, even for a short time.
Once again, while WordPress post revisions aren’t the only thing that contributes to the size of your database, they are a factor.
As I said above, search engines and visitors like sites that load in three seconds or less. So if you make sure your site loads within that time, you’ll keep both your visitors and the search engines happy, which is a win-win. Site performance isn’t the only thing that makes people and search engines happy, but as with everything else I’ve mentioned so far, it’s a factor. You can write the best content in the world, but if site speed is slow, your efforts are wasted.
OK, you’ve convinced me. How do I manage my WordPress post revisions?
Now that we’ve gotten all of the “whys” out of the way, I’m going to show you what WordPress post revisions are, how you can prevent them from being saved if you want, and how to remove them so that your database contains less clutter.
How do WordPress post revisions work?
WordPress creates a post revision in one of two ways. It creates one when the post auto-saves, and this happens once for each post for each user. It also creates a post revision every time you press “save draft.” WordPress lets you compare post revisions so you can track changes to a post, which is great for editors, and you can restore a revision if you need to undo a change and you don’t want to spend time manually doing it. This is useful if you’re deleting paragraphs of text. By default, WordPress keeps all post revisions. You have to give it instructions by way of wp-config if you want to either turn the feature off completely, or limit post revisions.
If you’re using WordPress.com to host your site, they’re taking care of things for you, which includes keeping your database free from clutter. If you’re using managed WordPress hosting, post revisions are also managed for you. But if you’re self-hosting, either on your own VPS or on a shared hosting account, you’ll have to manage them on your own.
I want to limit the number of post revisions WordPress keeps. How do I do this?
You can limit the number of WordPress post revisions by adding the following snippet to your wp-config file.
define( 'WP_POST_REVISIONS', 3 );
The number after the comma in the above example tells WordPress how many post revisions to keep. You can set this to whatever you want, but remember to keep it at the low end.
What about disabling post revisions altogether?
You can also use something similar to the above example to disable WordPress post revisions completely. To do this, you’ll need to change the example in the following way.
define( 'WP_POST_REVISIONS', false );
Removing the number and replacing it with “false” will tell WordPress not to save post revisions. Once you’ve added one of these constants to your wp-config file, you can now deal with the WordPress post revisions that are already in your database.
How do I get rid of WordPress post revisions that are already saved?
Even though you’ve added one of the above constants to your wp-config file, your database still contains any post revisions that were created as you’ve added content. In WordPress, each revision is a copy of the entire post, with the content that’s there when the revision is saved. So the next step is to remove the ones that are already in your database. By doing this, you’ll make your database smaller and easier to optimize. You can remove WordPress post revisions by running an SQL query, but if you’re not comfortable doing that, a simpler way to do it is with a plugin.
The Optimize Database after Deleting Revisions plugin will allow you to remove the WordPress post revisions you don’t need, and it will also let you keep them for a specific post should you decide to do that. It also optimizes your database after the revisions have been deleted, thus saving space in your database.
If you’re using this plugin to get rid of all revisions, and you know you’re not going to keep any, be sure to deactivate and delete it once you’re done using it so you don’t have unnecessary code hanging around your WordPress installation.
Managing WordPress post revisions is an easy way to make sure your website does not become slow or unresponsive, and if you’re on a small hosting plan, it’s also a great way to make sure you don’t reach your database size limits before you planned to. It’s also an excellent way to keep both your visitors and the search engines happy. If you have questions about anything in this tutorial, click here to get one-on-one support and I’ll be happy to walk you through any part of it.