When it comes to enabling caching on your WordPress site, you’ll find different types like browser caching, page caching, etc. There is another one called object caching that’ll also work great to improve your site’s slow loading speed.
It involves storing database queries and helps speed up PHP execution time, decreases the load on your database, and delivers content faster to your users when enabled on your WordPress site.
Even, if you run the AMP plugin in WordPress, you’ll see a recommendation stating “Persistent Object Caching is not enabled” in the site health screen. Therefore, in this post, I’ll discuss how to enable persistent object caching in WordPress.
Persistent Object Caching
Object caching stores database query results to serve the data from the cache next time it is needed. This way, it prevents repeated queries. Naturally, WordPress depends on a heavy database.
In this case, if you are running a site with high traffic and the requests to your site’s pages generate huge database queries, your server will become overwhelmed. Which, in turn, will affect your site’s performance negatively.
WordPress is designed with a built-in object cache, known as WP Object Cache, to automatically store any data in PHP memory. But, this object cache only stores data for a single page load, and at the end of the request, it discards objects in the cache. As a result, they have to rebuild the next time the page is requested.
And this is where persistent object caching comes into play. When it comes to cache objects between multiple page loads, this caching works more powerfully. Persistent object caching solutions like Redis and Memcached can be used in order to achieve and improve the power of the WordPress object cache.
The benefits of persistent object caching are-
- It cuts down unnecessary query executions and improves database efficiency by reducing database server strain.
- Improve your web hosting hardware performance.
- Provides a faster and improved accessibility to users, which leads to more user engagement.
- Helps in improving Core Web Vitals with a faster loading time and boosts your site’s SEO.
How to Enable Persistent Object Caching in WordPress?
To take your object caching of your WordPress site to the next level so that it can cache your database query persistently between page loads, follow the below ways.
So, here are the ways of how to enable persistent object caching in WordPress.
1. Use Redis
Before using the Redis Object cache plugin, make sure your site is using a PHP environment with the required PGP Redis extension and a working Redis server.
If your site is not compatible with using Redis, you should first set up Redis on your server and then install and activate the Redis object cache plugin.
Once activating the plugin, go to Settings, navigate to Redis, and click on “Enable object cache.” If your server doesn’t support the WordPress Filesystem API, simply copy the object-cache.php file manually from the /plugins/redis-cache/includes/ directory to the /wp-content/ directory.
One more thing that you should remember if you’re on managed WordPress hosting. With managed WordPress hosting, probably, your host offers object caching via Redis. In that case, you have to check the documentation of your host for information about enabling object caching.
And if you’re on shared hosting, you might want to consider upgrading your hosting package or switching the hosts.
2. Use Memcached
Before installing this plugin, follow the installation guide on the Memcached GitHub repository. After that, install and activate the WordPress Memcached Object Caching plugin. Once the installation and activation are done, navigate to the general setting from your WordPress dashboard and go to the page cache method. Then select Memcached, and it’s done.
There is no doubt that caching is hugely essential for any website, especially for content management systems like WordPress. To improve your website experiences, speed up the user interaction by reducing server loads, object cache works really well.
If your site contains bigger content with heavy data, then you’ll require a persistent object caching solution to cache those databases over multiple sessions.
I’ve discussed how to enable persistent object caching in WordPress in this guide. Hopefully, it’ll help you in this process.
So, do you use object caching on your site? If you have any questions on persistent object caching, leave a comment below.