How to set up a Redis server with LiteSpeed Cache Plugin?

LiteSpeed Cache Plugin is the most efficient way to speed up your website or blog, but it is not the only way. It’s great for most websites and blogs, but when your website or blog has a large amount of traffic you might want to consider using a Redis server or Memcached server as well.

This guide will teach you how to set up a Redis server with LiteSpeed Cache Plugin on a shared hosting environment. Many shared web hosting plans that I used have both Redis and Memcached installed but disabled by default. You have to login to cPanel account to activate them.

For this tutorial, I’m using Hawkhost Primary plan. I cannot guarantee the same will work on other hosting providers because of different configuration and features.

How to Enable Redis or Memcached in cPanel?

In cPanel, go to Server Application Manager.

From here, you have the option to enable Redis and Memcached if your server support them.

Note the Socket. You will need this information when configure Litespeed Cache.

Depend on your setup, you may need to select one. I prefer Redis over Memcached since it performs better on my site. It’s your choice.

After 5 minutes your server should be ready. Refresh the page to make sure your application is Online before going back to your WordPress website to turn on the Cache.

How to Setup Object Cache in Litespeed Cache?

When enabling “Object Cache” under Object Cache Settings and leave everything by default, you will see the “Connection Test Failed” warning.

This is usually caused by incorrect Host or the Port number.

By default, the Host field is set to “localhost” and port number is “empty“. You need to change these settings according to your server.

If you ignore the warning, your site may be still up and running. However, you will see a lot of connection refused errors like this in your log:

[02-Dec-2021 19:47:30 UTC] Connection refused
[02-Dec-2021 19:47:30 UTC] Connection refused
[02-Dec-2021 19:47:31 UTC] Connection refused
[02-Dec-2021 19:47:32 UTC] Connection refused

This file will get really big overtime unless you fix it.

Here is how you do it:

If you are using Redis Cache:

Change the Host field to your redis socket file

/home/yourhost/.applicationmanager/redis.sock

Set the port number to: 6379

If you are using Memcached:

Change the Host field to your memcached socket file

/home/yourhost/.applicationmanager/memcached.sock

Set the port number to: 11211

Don’t forget to save changes.

How to know if Redis cache is working?

If everything is setup correctly, it should pass the connection test.

You can also check the “error_log” file in the root of your WordPress installation. If you don’t see any connection refused error, it should be working fine.

If you have a large amount of traffic coming to your WordPress website or blog you will want to consider adding a Redis server or Memcached server with LiteSpeed Cache Plugin to speed up your website or blog.

Leave a Reply