This is an old revision of the document!


How to enable cache on LiteSpeed ADC

To enable cache on ADC, you will need to set up a server-level cache root, a virtual-host-level cache root, and enable cache in the virtual host cache settings. On the backend web server, you will need to install a LiteSpeed Cache plugin such as LiteSpeed Cache for WordPress plugin or LiteMage for Magento extension, etc. If there is no cache plugin available for your application yet, you can use rewrite rules to enable caching on the virtual host setting of Web ADC.

Enabling cache on ADC through a backend cache plugin is the recommended way since it is super easy for you to configure. The backend cache plugin manages most situations for you automatically, avoiding any manual configuration of rewrite rules.

The following explains how to enable cache on LiteSpeed Web ADC to communicate with WordPress, Magento, or other web apps that use an LSCache plugin via the following structure: LiteSpeed Web ADC (With Cache) > Back end web server > WordPress Application

Set Server-Level Cache Root on Web ADC

  • Navigate to LSLB Web Admin Console > Server > Cache
  • Set Storage Path to /home/lscache/

Set Virtual-Host-Level Cache Root on Web ADC

* Navigate to LSLB Web Admin Console > Virtual Hosts > Cache * Set Storage Path to /home/Litespeed443/lscache

Enable Cache on ADC

  • Set Check Public Cache to Yes

Install and Activate LiteSpeed Cache Plugin on Backend Web Server

Install and activate your plugin according to that plugin's directions:

Note 1: If there is no plugin available at this time, you can setup cache on ADC through rewrite rules on each virtual host.

Note 2: For Magento, you will need to set Enable LiteMage to yes on ADC and install the LiteMage plugin at the backend of web servers.

If a LiteSpeed cache plugin is not available, or you prefer to use rewrite rules to control the cache on ADC instead of backend web server, you can enable it on ADC through rewrite rules under virtual host/context. The advantage of this will be centralized cache management on ADC. The disadvantage of this is far fewer situations the rewrite rules can handle than with a cache plugin. No universal rules can fit everything. Also for different backend applications, you will need to set different rules to fit the requirements of that application. This is far more complicated than just selecting “Yes” and letting litespeed cache plugin to do all the rest for you automatically, right!? Don't worry, we are working on the rest of popular application cache plugins and will try to make them available as soon as we can.

The rewrite rules are similar to those on LSWS and you can check here for examples and details.

The following will give you an example on how to enable cache for Joomla:

The first three steps will be same as above for server-level cache root setup, virtual-host-level cache root setup and enabling cache in ADC settings. The difference is the fourth step: configure rewite rules on ADC virtual host instead of installing cache plugin on backend web server.

Set Server-Level Cache Root on Web ADC

  • Navigate to LSLB Web Admin Console > Server > Cache
  • Set Storage Path to /home/lscache/

Set Virtual-Host-Level Cache Root on Web ADC

* Navigate to LSLB Web Admin Console > Virtual Hosts > Cache * Set Storage Path to /home/Litespeed443/lscache

Enable Cache on ADC

  • Set Check Public Cache to Yes

Set Rewrite Rules to Configure Cache

Set rewrite rules under rewrite tab (make sure rewrite is enabled in the settings):

RewriteCond %{REQUEST_URI} ^.*\.(jpg|css|js|gif|png|svg)$ [NC]
RewriteRule .* - [E=Cache-Control:no-cache]
RewriteRule ^/(solutions|error-page|products) - [E=Cache-Control:max-age=120]

The above is only an example. You can set rules according to your need. You can also create some contexts if required and set rules there.

You can check if a page is being cached from WebADC by:

  1. Navigating to your site from a non-logged-in browser and using your browser's developer tools to check the response header.
  2. Enter the URL http://[Back_end_web_server_IP]/[wordpress-path] and check that there is no cache from response header.
  3. Enter the URL http://[Web_ADC_IP]/[wordpress-path]. Reload the page and look for X-LiteSpeed-Cache: hit in the response headers. If it's there, then the page is being served by the cache.
  4. Modify a post with the WordPress application, then press Ctrl+F5 to refresh http://[Web_ADC_IP]/[wordpress-path], you should see the updated posts.

To turn on the Web ADC Debug Log, you would follow the exact same steps that are laid-out here for LiteSpeed Web Server.

  • Admin
  • Last modified: 2017/10/30 18:52
  • by Jackson Zhang