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.
- 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:
- 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.