How to Use Redis as a Persistent Object Cache for WordPress

Updated on May 08, 2018

redis cache

Redis is an open-source, in-memory data structure store. In the context of WordPress, Redis can be used to store the values generated by WordPress’ native object cache in a persistent manner so that cached objects can be reused between pageloads.

Using a persistent object cache such as Redis allows for the reuse of cached objects rather than requiring the MySQL database to be queried a second time for the same object. The result is that Redis can reduce the load on a website’s MySQL database, simultaneously decreasing the response time of the site and increasing the site’s ability to scale and handle additional traffic.

Sites That Will Benefit Most From Redis

At Kinsta, page caching is built in for all sites on our platform. However, there are some sites that don’t make great use of page caching: some ecommerce sites, membership sites, forums and discussion boards, blogs with extremely active comment sections, and other types of highly dynamic websites.

Highly dynamic websites that cannot make good use of page caching are potential candidates for a persistent object caching option such as Redis.

Redis will generally not help the load time of static blogs, informational business websites, and news websites unless the sites make very poor use of our page caching.

Adding Redis to a Site at Kinsta

If you would like to add Redis to your site hosted at Kinsta, follow these steps:

  1. Contact Kinsta’s support team and request to have Redis added to your site.
  2. Kinsta’s support team will install Redis in your site container and our billing team will add the Redis add-on subscription to your account.
  3. Once Redis has been installed in the site container you will need to install a plugin on your site to integrate Redis with WordPress’ object caching. There are several possible plugins you could use for this purpose. The two most popular options among our users are WP Redis and Redis Object Cache.

Important note if your site has both a STAGING and a LIVE environment: If your STAGING site is no longer needed please delete it. It can then be recreated following the installation of Redis on the LIVE site. If your STAGING site cannot be deleted, it will be necessary to add Redis (and the Redis plugin) to the STAGING site container. If this is not done then the next time STAGING is pushed LIVE the Redis installation in the LIVE environment will be overwritten and removed.

In addition, note that if you do opt to discontinue using Redis you may ask to have Redis removed from your site container and you should ask to have the Redis add-on subscription canceled. You will receive a refund of any unused Redis subscription add-on fees issued according to our refund policy.

Using Redis With a WordPress Website

Once Redis has been installed and integrated with your site with a plugin it will run silently in the background.

To clear the Redis object cache you can use the Clear Cache option added to your website admin area by the Kinsta Cache plugin. This button will clear both our page cache and any object caching active on the site.

Clear cache from WordPress admin toolbar

Clear cache from WordPress admin toolbar

It is critical that you test your site thoroughly after enabling object caching, being careful to review all critical processes on your website with multiple user profiles to ensure that cached objects aren’t be reused incorrectly.

If you do find that cached objects are being used incorrectly it may be possible to exclude specific groups of objects from object caching with the wp_cache_add_non_persistent_groups function. Manipulating object cache performance is outside the scope of Kinsta’s support for Redis and will require the involvement of a qualified WordPress developer.

Limits to Kinsta’s Support for Redis

Kinsta’s support for Redis is limited to installing Redis and any required dependencies in the site container and ensuring that Redis is available for use by WordPress. Integrating Redis with your website and excluding specific groups of objects from the cache is the responsibility of each website owner and if you find that you need assistance with proper integration of Redis with your website you will need to retain the services of a qualified WordPress developer.

Was this article helpful?
No, or there was something off

Hand-picked related articles

Send this to a friend