Setting up LSCache for WordPress on OpenLiteSpeed
This guide will take you through the steps to configure OpenLiteSpeed’s cache module, install and activate the LSCache for WordPress plugin, and modify a virtual host to use a .htaccess file for your WordPress installation.
Pre-Installation Requirements
- OpenLiteSpeed Web Server 1.4.43+ installed
- WordPress installed
- Virtual Host set up
- Listener set up
We recommend using the ols1clk script whenever possible to quickly and easily install these requirements. If you use the script to install these, you should only have to enable the LiteSpeed Cache for WordPress plugin from within the WordPress Dashboard, and your cache should work.
Cache Module Configuration
In version 1.4.43+, the Cache Module will be automatically installed and enabled by default, so you don’t need to change anything.
The following steps apply only when you want to change Cache Module Parameters or you are using an OLS version under 1.4.43:
- Navigate to Server Configuration > Modules in your Web Admin Console.
- Click the Edit button.
- Modify the Module Parameters configuration to match the following:
checkPrivateCache 1
checkPublicCache 1
maxCacheObjSize 10000000
maxStaleAge 200
qsCache 1
reqCookieCache 1
respCookieCache 1
ignoreReqCacheCtrl 1
ignoreRespCacheCtrl 0
enableCache 0
expireInSeconds 3600
enablePrivateCache 0
privateExpireInSeconds 3600
- Click the Save button.
- Gracefully restart your server.
Rewrite Configuration and Read From .htaccess File
Version 1.4.43+ supports the Auto Load from .htaccess
function.
Navigate to Virtual Hosts in your Web Admin Console.
Click the Rewrite tab, and modify the following settings:
Enable Rewrite: Yes
Auto Load from .htaccess: Yes
LiteSpeed Cache WordPress Plugin
- Navigate to your WordPress Admin Dashboard (yoursite/wp-admin) and log in.
- Click on Plugins > Add New.
- Search for
LiteSpeed Cache
- Click on the Install button under the LiteSpeed Cache plugin name.
- Next click the “Activate Plugin” link.
- Navigate to your LiteSpeed Web Admin Console again and gracefully restart your server.
Verify That the Cache Setup is Correct
- Log out of your site and navigate to its homepage.
- Right-click and Inspect.
- Refresh the page.
- After the page loads, click the Network tab from the Inspector.
- Locate and click on the resource that contains your URL.
- Click the Headers sub-tab.
- Scroll down to the Response Headers section. You should see the following Response Headers:
X-LiteSpeed-Cache: hit
Possible Errors and How to Resolve Them
Neither X-LiteSpeed-Cache Header Nor X-LiteSpeed-Cache-Control Header
If you have this issue, things did not get set up properly in both the server and cache. Verify that your OLS configurations are correct and uninstall and reinstall the LiteSpeed Cache for WordPress plugin. If, after both these steps, you still have a problem, uninstall both and try again from the start.
Always X-LiteSpeed-Cache: miss
If you receive an X-LiteSpeed-Cache-Control
header, but never receive an X-LiteSpeed-Cache: hit
header, caching is not working.
The 3 most common causes of this case and their fixes are:
- Something went wrong during installation – Navigate to your WordPress Admin Panel and uninstall and reinstall the LiteSpeed Cache plugin.
- Cache is disabled – Navigate to your WordPress Admin Panel and enable the LiteSpeed Cache plugin.
- You are using multi-site – For multi-site WordPress installations, by default the cache plugin is not active. Navigate to your WordPress Admin Panel and enable the LiteSpeed Cache plugin.
X-LiteSpeed-Cache-Control Header But No X-LiteSpeed-Cache: hit/miss Header
If you receive an X-LiteSpeed-Cache-Control
header but no X-LiteSpeed-Cache: hit
or X-LiteSpeed-Cache: miss
header, your server cache lookup settings may be misconfigured.
Verify that virtual host and context level cache module settings do not overwrite the checkPublicCache 1
cache module setting for this site.
X-LiteSpeed-Cache: no-cache
If you are receiving the X-LiteSpeed-Cache: no-cache
response header, it is likely that you are logged-in. Please log out and try refreshing the page again.
If you have an issue that is not listed above or your issue was not solved by following the corresponding steps, please post your issue with as much detail as you can in our OLS forums: https://forum.openlitespeed.org/
If you believe your problem to be a bug, please send an email to bug (at) litespeedtech (dot) com with as much detail as you can to submit a bug report to our OpenLiteSpeed devs.