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.
- OpenLiteSpeed Web Server 1.4.19+ 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 used the script to install these, you should only have to modify the cache module’s settings in the next section and enable the LiteSpeed Cache for WordPress plugin and your cache should work.
Cache Module Configuration
- Navigate to Server Configuration > Modules in your Web Admin Console.
- Click the Add button.
- In the Module field, type
- Copy and paste the following text into the Module Parameters field:
enableCache 0 qsCache 1 reqCookieCache 1 respCookieCache 1 ignoreReqCacheCtrl 1 ignoreRespCacheCtrl 0 enablePrivateCache 0 privateExpireInSeconds 1000 expireInSeconds 1000 storagePath cachedata checkPrivateCache 1 checkPublicCache 1
- Click the Save button.
- Gracefully restart your server.
- Navigate to Virtual Hosts in your Web Admin Console
- Click on the name of your WordPress Virtual Host.
- If your WordPress is in a context, click the Context tab and modify the following settings:
Enable Rewrite: Yes Rewrite Inherit: Yes Rewrite Rules: rewriteFile /path/to/wordpress/.htaccess
- If your WordPress is not in a context, you should click the Rewrite tab and modify the following settings:
Enable Rewrite: Yes Rewrite Rules: rewriteFile /path/to/wordpress/.htaccess
LiteSpeed Cache WordPress Plugin
- Navigate to your WordPress Admin Dashboard (yoursite/wp-admin) and log in.
- Click on Plugins > Add New.
- Search for
- 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 and
Where 1800 is your site’s Front Page TTL Setting in the WordPress Plugin.
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.
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: http://openlitespeed.com/
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.