How to Use Redis Caching in WordPress

Last Updated -


Redis is a great way to speed up your WordPress sites. By using Redis to cache various database queries, your site can run faster than ever before and even save you money by using less server resources.

In this article, we'll show you how to configure Redis to cache database queries within WordPress.

  1. Begin by accessing your VPS via SSH.
  2. Next, access the site that you want to activate Redis caching on.

    cd ~/sites/example.com
  3. Next, edit your wp-config.php file to include the following lines:

    define('WP_REDIS_PORT', 6380);
    define('WP_CACHE_KEY_SALT','my-site-nickname-here');
  4. If you're on one of our High Availability plans, you'll also need to set the Redis Host. If not, you can skip to step 5.

    On the primary server, run the ifconfig command to get your primary server's IP (10.x.x.x), then add the following to your wp-config.php file:

    define('WP_REDIS_HOST', '10.x.x.x');
  5. Next, install and activate the Redis Object Cache plugin from the WordPress repository. This can be done with WP-CLI using the following command:

    wp plugin install redis-cache --activate
  6. Now that the Redis Object Cache plugin is installed and activated, log into your WordPress admin dashboard and use the left side navigation menu to go to Settings, then to Redis.
  7. Finally, verify that the Redis Object Cache plugin has the proper settings (Port is set to 6380 and the Cache Key Prefix is populated), then click Enable Object Cache.

    Note: It is extremely important that your port is set properly to 6380. If not, you will lose important configuration data and cause your site(s) to become unavailable until that data gets reapplied.

That's it! Redis caching is now enabled and ready to go! For further information on optimization your WordPress site, take a look at our WordPress optimization guide.

 

Related Topics

Pagely is the Managed WordPress Hosting Platform designed to exceed the needs of media, business, and Enterprise customers alike. We help the world's biggest brands scale WordPress.

Copyright © 2006-2017 Pagely, Inc. All rights reserved.
Pagely® and WordPress® are registered trademarks.

Pagely
Powered by Zendesk