How to configure WordPress to use Redis

This article describes how to configure WordPress to use Redis.

Redis is an open-source memory object caching system that websites can use to help accelerate page load times. Redis works by caching in RAM frequently accessed data, such as the results of API calls, database queries, and more. It is commonly used as an alternative to Memcached, another caching system.

Adding Redis caching to WordPress can help improve your site's performance and page load times.

 

Redis is currently enabled on Cloud Hosting, WordPress Hosting, Managed VPS, and Managed Dedicated server accounts.

 

WordPress plugin support for Redis

There are several plugins available for integrating Redis caching with WordPress. This article describes how to do so with two of the most popular Redis plugins, Redis Object Cache and WP Redis.

You can use whichever plugin you prefer (and you should only use one of these plugins at a time, not simultaneously). With Redis Object Cache, you can do all configurations through the WordPress UI. For WP Redis, you use the command line to complete the configuration.

 

Option #1: Redis Object Cache plugin

The Redis Object Cache plugin enables you to easily set up your WordPress site to use Redis.

 

By default, Redis Object Cache uses the WordPress database table prefix defined in wp-config.php for its own key prefix in the Redis cache. If you have multiple WordPress sites that use the same MySQL table prefix, content from the sites can become mixed together in the Redis cache and cause site display problems. Note that this scenario only happens if all of the following conditions are true:

  • You installed two or more WordPress sites manually (in other words, you did not use Softaculous to install the sites).
  • Two or more of the manually installed WordPress sites use the same database table prefix (for example, the default table prefix of wp_).
  • The WordPress sites that share the same database table prefix also have Redis Object Cache installed and activated.

In such a scenario, you can disable Redis Object Cache and the site display issues will be resolved. Consider changing the sites' database table prefixes, or changing the cache key prefix for Redis Object Cache. For more information, please see https://github.com/rhubarbgroup/redis-cache/wiki.

 

To install and configure Redis Object Cache on your WordPress site, follow these steps: 

  1. Log in to WordPress as the administrator.
  2. On the Dashboard in the left sidebar, click Plugins, and then click Add New
  3. On the Add Plugins page, in the Search plugins text box, type redis object cache and then press Enter.
  4. Locate the Redis Object Cache section, and then click Install Now:

  5. Configure the plugin:

    • If you have a Managed VPS or Dedicated Server, click Enable Object Cache. When you see green checkmarks for StatusDrop-in, and Filesystem, Redis is activated and running for WordPress:
      • If you have a Cloud Hosting, WordPress or Reseller account, follow these steps:

        1. In the directory where you installed WordPress, use your preferred text editor to open the wp-config.php file. Just above the /* “That's all, stop editing! Happy publishing. */ line near the end of the file, paste the following text:
          define( 'WP_REDIS_SCHEME', 'unix');
          define( 'WP_REDIS_PATH', '/home/username/tmp/redis.sock');
          
        2. Replace the username with your own account username.
        3. Save your changes to the wp-config.php file.
        4. In WordPress, on the Redis Object Cache page, click Enable Object Cache. When you see green checkmarks for StatusDrop-in, and Filesystem, Redis is activated and running for WordPress.
    • You do not need to do anything further to take advantage of performance improvements from Redis caching. The following options are available:

      • To view statistics about Redis caching on your site, click the Metrics tab.
      • To view detailed configuration and debugging information, click the Diagnostics tab.
      • To flush the Redis cache, click Flush Cache.
      • To disable Redis caching, click Disable Object Cache.
    •  
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

 Memcached Vs. Redis which is best for my website ?

Memcached vs Redis: Direct Comparison Both tools are powerful, fast, in-memory data stores that...

 How do I enable Memcached / Object Cache for Litespeed?

WebGee now supports Memcached to improve performance via Object Caching, which reduces requests...

 How To: Enable Object Caching with Redis using LSCache

In this article, we're going through enabling Redis Caching which is really useful to enhance...

Powered by WHMCompleteSolution