Actually, no, you probably shouldn’t; or more to the point, you probably don’t need to.
Since WordPress v6.1 the “Dashboard – Tools – Site Health” check has started recommending that some sites should be using a “Persistent Object Cache” without actually explaining why.
So let’s unpack that. First of all …
What is a persistent object cache?
The Health Check panel answers that as follows …
A persistent object cache makes your site’s database more efficient, resulting in faster load times because WordPress can retrieve your site’s content and settings much more quickly.
… which is great but …
Can you actually use a persistent object cache on your website?
Probably not. Reading on from wordpress.org …
For your site to use persistent object caching, your hosting provider must offer you a particular type of server, a cache server. Popular cache servers are Redis and Memcached.
So are you stuck with this warning? Actually no! In most cases, when you find out the actual cause behind the warning, you’ll soon find out how to stop it appearing!
What is causing “You should use a persistent object cache” to appear?
The WordPress Health check takes a look at your database and brings up this warning if …
- You have more than 500 options set to autoload or more than 1,000 options in total in the wp_options table
- You have more than 100,000 bytes (100Kb) of options in the wp_options table
- You have more than 1,000 comments in the wp_comments table
- You have more than 1,000 posts in wp_posts table
- You have more than 1,000 terms in wp_terms table
- You have more than 1,000 users in wp_users table
Chances are if you have more than 1,000 comments, terms or users then you have a large site that probably does indeed require a persistent object cache but more often than not, the wp_options and wp_posts tables are the cause and can be reduced; and here’s how we do it …
How can I reduce the number of rows in the wp_posts table?
One very quick way is to delete all the post revisions. By default, WordPress will save all the changes you make to a post or page each time you update as revisions. Each revision is saved in the wp_posts table with the post_type set to “revision”. It’s not uncommon for a fairly small site to have hundreds of these stored in the database!
Our sister company, Webd Ltd, have developed a WordPress Maintenance plugin that will detect and allow you to easily delete these revision.
It will even let you choose how many of the latest revisions you’d like to keep site-wide and will delete the rest on a daily schedule.
How can I reduce the number and size of options in the wp_options table?
Reducing the number of options in the wp_options table is not so straight forward but by no means impossible! The afore-mentioned WordPress Maintenance plugin developed by our sister company, Webd Ltd, has gone some way to help with this.
If it detects that you have more than 500 autoload options or more than 100,000 bytes of options, it will start analysing your sites use of options; remembering all the options that your website is actually using.
After a short period of time, it will be able to fairly accurately report not only which options aren’t being used but also which of these are the top 10 largest!
You can then click the search icon next to each option which will take you to Google to see what is responsible for creating it. If it’s been left by a plugin you no longer use (which is very likely) then you can click the trashcan icon to delete it!
Soon enough you’ll have reduced the wp_options table sufficiently to prevent the warning in the Site Health tool!
And, as an added bonus, having fewer posts in the wp_posts table and fewer options in the wp_options table will almost certainly have a profound benefit on your website’s speed.
One final word of warning … always take a full backup of your database and filesystem before undertaking any work like this on your site!
I still need a persistent object cache … what now?
Some large websites do actually need a persistent object cache. If you want us to help you set one up, contact us. We’ve successfully setup Redis persistent object cache for several of our clients and doing so can have some decent results shaving time from your page loads.