If your hosting package contains more than 2GB RAM, you can use Redis. Redis is an advanced caching tool which stores frequently used data in the RAM memory. This allows you to gain a significant speed increase. Especially heavier WordPress websites in combination with Woocommerce, have a lot to gain from using Redis.
Choose method 1 (quick) or method 2 (expansive)
You can set up Redis in multiple ways. We will discuss two plugins here from which you can choose: Redis Object Cache (method 1) or W3 Total Cache (method 2). When following the first method, you will only set up Object Cache. For maximal performance for larger websites and webshops, method 2 is recommended since you have more configuration options.
Is your website compatible with the latest stable PHP-version?
We recommend using the latest stable PHP-version for optimal performance. You can set this within the PHP-selector within DirectAdmin. Do make sure that the Redis-module is checked as well.
Method 1: Redis Object Cache
In comparison to W3 Total Cache, the Redis Object Cache plugin is simpler and has less settings. If you want to use Redis and prefer an easy set up, choose for this method.
- Log into the backend of your WordPress installation (example.com/wp-admin).
- Click in the menu on the left on 'Plugins' and then on 'Add new'.
- Search for 'Redis Object Cache', install the plugin and then click 'Activate'.
-
Now open the file wp-config.php, for example through the File Manager in DirectAdmin or the FTP-program of your choice. Look for the following line:
/* That's all, stop editing! Happy publishing. */ -
Just above that line, add the following lines and save the changes:
define('WP_REDIS_PATH', 'tmp/redis.sock'); define('WP_REDIS_SCHEME', 'unix');It needs to look like this:
Note: the default Redis-database is 0. If you set up Redis for multiple websites within the same hosting package, you are better off setting a different Redis-database for every website. You can choose between the range of 0 and 15. For multiple websites, use the lines below, and set the number behind WP_REDIS_DATABASE to such a number.
define('WP_REDIS_PATH', 'tmp/redis.sock'); define('WP_REDIS_SCHEME', 'unix'); define('WP_REDIS_DATABASE', '1');For maximum performance, it is however better to host the multiple website in their own hosting packages.
- Go back to your WordPress dashboard to 'Plugins', then 'Installed plugins' and then click under 'Redis Object Cache' on 'Settings'.
- Click on 'Enable Object Cache' to activate Redis.
- Check if it says 'Connected' under 'Status'. If that is the case, you have successfully set up Redis!
If you want to, you can combine Redis with other caching plugins, such as WP Super Cache or WP Rocket. However, never use these at the same time as W3 Total Cache (method 2) or another plugin with integrated Redis support. Otherwise, data is written twice to Redis and that is strongly discouraged.
Method 2: W3 Total Cache
This plugin offers more options when compared to Redis Object Cache plugin. If you want more performance, are familiar with W3 Total Cache and you know what you are doing, choose this method.
- Log into the backend of your WordPress installation (example.com/wp-admin).
- Click in the menu on the left on 'Plugins' and then on 'Add new'.
- Search for 'W3 Total Cache', install the plugin and click on 'Activate'.
- In the menu on the left, click on 'Performance', and then 'General settings'. Search for the settings for 'Object Cache'. Check 'Enable' next to 'Object Cache' and set 'Object Cache Method' to 'Redis'.
If you have done the adjustments, make sure the click on 'Save settings'. - Go to 'Performance' and then 'Object Cache' and change the 'Redis hostname' to /tmp/redis.sock.
Optional: the default Redis database is 0. If you have multiple websites within your hosting package which all use Redis, use different Redis databases. You can choose from 0 up and including 15. - Once you have entered the hostname, click on 'Test' to check if the connection is successful. If so, click on 'Save all settings'.
- Go back to 'Performance' and then 'General settings' and search for the settings for 'Page Cache'. Check 'Enable' behind 'Page Cache' and select 'Page Cache Method' to 'Redis'.
Click on 'Save all settings'. - Go to 'Performance' and then 'Page Cache' and change the 'Redis hostname' to /tmp/redis.sock.
Click on 'Test' to see if the connection is successful. If so, click on 'Save all settings'. - On the left in the menu, click on 'General settings' and find the settings for 'Database Cache'. Check 'Enable' and switch the 'Database Cache Method' to 'Redis'.
- Go to 'Performance' and then 'Database Cache' and change the 'Redis hostname' to /tmp/redis.sock.
Click on 'Test' to check if the connection is successful. If so, click on 'Save all settings'.
If you own the paid version of W3 Total Cache, you can set up Fragment Cache in a similar fashion. Are you an advanced user? You can then take a look at the settings for Minify.
Testing settings
Do note that it is hard to recommend settings which fit for all websites. If speed is what you are looking for, it is generally recommended to use Full Page Cache. Object Cache is also responsible for both a faster frontend and backend.
Every website is different. Make sure to test the speed, before and after you have made any changes. You can use WebPagetest or PageSpeed Insights to do so. Then you will know whether your changes have the desired effect, or if you need to reverse them.