Website Performance

Does your WordPress site need a Persistent Object Cache

Does your Wordpress site need a Persistent Object Cache

“You should use a persistent object cache” is the result of a new health check introduced in WordPress 6.1. This article will explain why you’re seeing this recommendation and what you can do to fix it if you need to at all.
“You should use a persistent object cache”

What is A Persistent Object Cache?

A persistent object cache is a software mechanism used to store frequently accessed data or objects in a cache, which can be quickly accessed to improve application performance. The cache is usually implemented as a part of the application’s memory or as a separate software component, and it stores data retrieved from a database, file system, or other data source. This data is typically accessed frequently and has a high cost to retrieve from the source, so caching it can significantly improve application performance. The persistent aspect of the cache means that the data is stored on a non-volatile storage medium, such as a hard disk or solid-state drive, so that it can survive across application sessions and system restarts. This ensures that the data is always available and doesn’t need to be reloaded into the cache every time the application starts up. Overall, a persistent object cache can be an effective way to improve application performance by reducing the amount of time spent retrieving frequently accessed data from a slow data source.

How does “WordPress Health Check” know if I need a Persistent Object Cache?

As of WordPress 6.1, a new specific Cache Health Check has been added. There are two health checks, a Full Page cache check and also a Persistent Object Cache check. Basically, the object cache uses a set of “tests” to decide if an object cache would be beneficial.

Here are the variables that are used:

 * Override the whole $thresholds array, or any specific indexes as required. */add_filter( 'site_status_persistent_object_cache_thresholds', function( $thresholds ) {    $thresholds = array(        'alloptions_count' => 600,        'alloptions_bytes' => 200000,        'comments_count'   => 2000,        'options_count'    => 2000,        'posts_count'      => 2000,        'terms_count'      => 2000,        'users_count'      => 2000,    );    return $thresholds;} );

We’re not going to go into each variable here, but we don’t necessarily agree this is the only way you would test if a site would benefit from an object cache. As mentioned before, if a site doesn’t create dynamic content on a per-user basis it’s unlikely an object cache is the source of its performance issues. A page cache in this scenario would be much more beneficial. That said, there are certainly lots of cases where a site can benefit from Object Caching.

How do I add a Persistent Object Cache to WordPress?

To add a persistent object cache you will need to make sure your site has access to a Redis or Memcached server.
Once that’s the case you can use a plugin on WordPress to enable the use of the object cache. Here are some popular options:

 

Nevertheless, it is imperative to acknowledge that not all WordPress websites necessitate the implementation of a Persistent Object Cache. Websites that have limited traffic and contain uncomplicated content may not experience substantial advantages from the adoption of caching mechanisms. In addition, certain providers of managed WordPress hosting may offer server-level caching solutions that have been potentially optimised for enhanced performance.

Prior to implementing a Persistent Object Cache, it is essential to evaluate the specific requirements and performance limitations of your website. It is advisable to undertake performance testing in order to ascertain the potential benefits of implementing caching mechanisms, including object caching, on system performance. It is important to note that although caching can enhance performance, it necessitates appropriate configuration and monitoring to prevent the delivery of outdated or inaccurate data to users.

More WordPress Error:

Fix error “500 Internal Server Error” in WordPress

Leave a Reply

Your email address will not be published. Required fields are marked *