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 using the Redis Object Cache plugin to cache database queries within WordPress.
We highly recommend using our drop-in solution instead of this plugin. While it does work well if you have a specific need for it, such as if your site uses Advanced Custom Fields, our drop-in solution is much more stable, supported, easier to configure.
If you don't have a specific need for using this 3rd-party plugin, you'll likely want to follow the steps outlined for our drop-in solution instead of this article.
Configuring the Redis Object Cache Plugin
- Begin by accessing your VPS via SSH.
- Next, access the site that you want to activate Redis caching on.
- 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');
- 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:
- 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
- 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.
- 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.