Enable Redis Caching in WordPress
Growing with your website is fantastic: more visitors, more customers, and you also generate more revenue. Great news, then! But you do notice that your website is slowly starting to become a bit slower. The loading time of your website increases, and maybe you are now looking for ways to improve the speed of your WordPress site. A great way to give your WordPress site a boost is to use Redis Cache. At mijn.host, Redis Caching is included with every hosting package. You can read how to activate this in this article.
What is Redis cache and how does it work in WordPress?
Redis is a so-called 'cache mechanism'. What it actually does is store a lot of data in advance, so that the visitor can retrieve it from the server at lightning speed. As a result, a large, slow MySQL database is not loaded for every visitor, but rather a scaled-down copy. The correct data is looked up and served based on each request.
By working with this method of serving, you can speed up WordPress considerably. Because WordPress is based on MySQL and stores all data in it, you will quickly notice the difference with Redis. The Redis cache grows flexibly, so less and less data needs to be looked up in MySQL. A smart system, that Redis.
- Log in to DirectAdmin, see this article for more information: https://mijn.host/kb/webhosting/hoe-log-ik-in-op-directadmin
- Are you logged in to h30.mijn.host or lower (such as h8.mijn.host)? Then go to Extra Features > Redis Management.
- Are you logged in to h31.mijn.host or higher (such as h32.mijn.host)? Then go to Advanced Features > Redis.
- Are you logged in to h30.mijn.host or lower (such as h8.mijn.host)? Then go to Extra Features > Redis Management.
- The next step is to activate Redis.
- Are you logged in to h30.mijn.host or lower? Then click on Create new redis instance. You will then see the screen "Redis instance is successfully created". After that, click on Back to list.
- Are you logged in to h31.mijn.host or higher? Then set the Redis option to Enabled. Copy the text next to the Path to redis socket file option. In our example, this is "/home/auwdomei/.redis/redis.sock".
- Are you logged in to h30.mijn.host or lower? Then click on Create new redis instance. You will then see the screen "Redis instance is successfully created". After that, click on Back to list.
- Log in to your WordPress installation via uw-domein.nl/wp-admin (replace uw-domein.nl with your own domain name).
Select the LiteSpeed Cache plugin in the left menu, and click on Cache in the submenu.
Navigate to the Object tab. Enter the following details here.- Are you logged in to h30.mijn.host or lower? Then use the settings below.
Object Cache
On
Method
Redis
Host
localhost
Port
Enter the port number of the created Redis instance
Username
Leave empty
Password
Enter password of crcreated Redis instance in
- Are you logged in to h31.mijn.host or higher? If so, use the settings below.
Object Cache
On
Method
Redis
Host
Enter the previously copied path of the Path to redis socket file option here.
In our example, this is "/home/auwdomei/.redis/redis.sock".
Port
0
Username
Leave empty
Password
Leave empty
Are you experiencing connection issues with the Redis connection? Open the wp-config.php file and add these lines:define( 'WP_REDIS_SCHEME', 'unix' );
Replace [gebruiker] with your DirectAdmin username.
define( 'WP_REDIS_PATH', '/home/[gebruiker]/.redis/redis.sock' );Note, add this code above this line:/* That's all, stop editing! Happy blogging. */
- Are you logged in to h30.mijn.host or lower? Then use the settings below.
- Save the changes. Now go back to the top and click on More Information next to the Connection Test. Then click on Send Again.
It should now say Connection Test: Passed. The Redis instance has now been created and is ready for use.
Redis Caching is not working yet
If Redis Caching is still not working, the Redis PHP extension might not be enabled. The status block will then show Redis Extension: Disabled
If this is the case, it can be easily fixed by enabling the extension in your PHP options. Follow the steps below.
- Log in to the mijn.host control panel.
- Navigate to your hosting plan.
- Now select Advanced > PHP settings in the horizontal menu.
- Once you are on that page, click on the PHP extensions tab.
- You will now see all available PHP extensions, search for "redis" and check the box to the left of it.
- Now click the Change button at the bottom to save this.
The Redis PHP extension should now be enabled, refresh the Redis page in your WordPress website and check if the connection test has now passed.
Redis Caching is activated
You have successfully activated Redis Caching and your website will now load faster. If you need any help, feel free to ask our support staff. They will be happy to assist you.
Still have questions? Get in touch.