Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
litespeed_wiki:cache:webadc [2017/10/30 15:22]
Jackson Zhang [Enable cache on Web ADC]
litespeed_wiki:cache:webadc [2018/05/15 13:29]
Jackson Zhang [Enable Cache on ADC]
Line 1: Line 1:
-====== ​LSCache + LiteSpeed ​WebADC ​======+====== ​How to enable cache on LiteSpeed ​ADC ======
  
-This guide explains how to set up LiteSpeed WebADC ​to communicate with WordPress ​(or other web apps that use an LSCache ​plugin) via the following structure:+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_wiki:​cache:​lscwp|LiteSpeed Cache for WordPress]] plugin ​or [[litespeed_wiki:​cache:​litemage|LiteMage for Magento]] extension, etc. If there is no cache plugin ​available for your application yet, or the backend end server with a third party and impossible to enable litespeed cache plugin on it,  you can use rewrite rules to enable caching on the virtual host setting of Web ADC.
  
-LiteSpeed WebADC (With Cache) > Back end web server > WordPress Application+===== Enable ​Cache on ADC With Plugin on Backend Web Server ===== 
 +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. ​
  
-===== Enable cache on Web ADC ===== +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 
-  * Navigate to **LSLB Web Admin ConsoleServerCache** + 
-    ​- ​Set **Storage Path** to ''/​home/​lscache/'' ​+==== Set Server-Level Cache Root on Web ADC ==== 
 +  * Navigate to **LSLB Web Admin Console ​Server ​Cache** 
 +  ​* ​Set **Storage Path** to ''/​home/​lscache/'' ​
 {{:​litespeed_wiki:​cache:​adc-server.png?​|}} {{:​litespeed_wiki:​cache:​adc-server.png?​|}}
-  ​* Navigate to **LSLB Web Admin ConsoleVirtual HostsCache** + 
-    ​- ​Set **Storage Path** to ''/​home/​Litespeed443/​lscache''​ +==== Set Virtual-Host-Level Cache Root on Web ADC ==== 
-    ​- ​Set **Check Public Cache** to ''​Yes''​+ * 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''​
 {{:​litespeed_wiki:​cache:​adc-vh.png?​|}} {{:​litespeed_wiki:​cache:​adc-vh.png?​|}}
-  * Install and activate plugin for WordPress ​at backend web servers by following this [[litespeed_wiki:​cache:​lscwp:​installation#​installation|Installation article]]+  * **Check Private cache** normally leave it as blank at most of the cases. Set it to ''​Yes''​ only if there is a private ESI block.  
 +==== Install and Activate LiteSpeed Cache Plugin on Backend Web Server ==== 
 +Install and activate ​your plugin ​according to that plugin'​s directions:​ 
 +  * [[litespeed_wiki:​cache:​lscwp:​installation#​installation|LSCache ​for WordPress]] 
 +  * [[litespeed_wiki:​cache:​lscxf:​installation#​installation|LSCache for XenForo]] 
 +  * [[litespeed_wiki:​cache:​lscps:​installation#​installation|LSCache for PrestaShop]] 
 +  * [[litespeed_wiki:​cache:​litemage:​installation#​detailed_installation_guide|LiteMage for Magento 1]] 
 +  * [[litespeed_wiki:​cache:​litemage2:​installation#​installation|LiteMade for Magento 2]]
  
-''​Note 1'': ​The above steps are for most applications other than MagentoYou will need to install ​Litespeed cache plugin ​for that application ​at back end server, ​which is recommended way If there is no plugin ​available at this time, you can setup cache on ADC through rewrite ​rules on each virtual host.+''​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. 
 + 
 +===== Enable Cache on ADC Without Plugin on Backend Web Server ===== 
 + 
 +If a LiteSpeed cache plugin is not available, or the backend ​end server ​with a third party and impossible to enable litespeed cache plugin on itor you still prefer to centralize all cache settings on ADC instead of backend 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 pluginNo 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 automaticallyright!? 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 [[litespeed_wiki:​cache:​no-plugin-setup-guidline|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/''​  
 +{{:​litespeed_wiki:​cache:​adc-server.png?​|}} 
 + 
 +==== 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''​ 
 +{{:​litespeed_wiki:​cache:​adc-vh.png?​|}} 
 + 
 +==== 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] 
 +   
 +{{ :​litespeed_wiki:​cache:​adc-cache-rewrite-example.png?​600 |}} 
 +     
 +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.
  
-''​Note 2'':​ For Magento, you will need to set "​Enable LiteMage"​ to "​yes"​ on ADC and install LiteMage plugin at the backend of web servers. 
 ===== Testing ===== ===== Testing =====
  
-You can check if a page is being cached from WebADC ​by: +You can check if a WordPress ​page is being cached from Web ADC by: 
     - Navigating to your site from a non-logged-in browser and using your browser'​s developer tools to check the response header.     - Navigating to your site from a non-logged-in browser and using your browser'​s developer tools to check the response header.
     - Enter the URL ''<​nowiki>​http://​[Back_end_web_server_IP]/​[wordpress-path]</​nowiki>''​ and check that there is no cache from response header.     - Enter the URL ''<​nowiki>​http://​[Back_end_web_server_IP]/​[wordpress-path]</​nowiki>''​ and check that there is no cache from response header.
     - Enter the URL ''<​nowiki>​http://​[Web_ADC_IP]/​[wordpress-path]</​nowiki>''​. 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.     - Enter the URL ''<​nowiki>​http://​[Web_ADC_IP]/​[wordpress-path]</​nowiki>''​. 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.
-    - Modify a post with the WordPress application,​ then press Ctrl+F5 to refresh ''<​nowiki>​http://​[Web_ADC_IP]/​[wordpress-path]</​nowiki>'',​ you should see the updated posts.  ​+    - Modify a post with the WordPress application,​ then press **Ctrl+F5** to refresh ''<​nowiki>​http://​[Web_ADC_IP]/​[wordpress-path]</​nowiki>'',​ you should see the updated posts.  ​ 
 + 
 +==== Will I see "​Cache-Control:​max-age"​ header"​ when I use lscache? ==== 
 +No. Please be aware there are two different concepts: ''​Cache-Control:​max-age''​ is a regular cache response header which controls the cache behavior of a browser or public proxy, //not// LSCache from the server side.  While ''​[E=cache-control:​max-age=120]''​ is to control LiteSpeed'​s internal server cache and //​won'​t//​ affect browser cache.  
 +Our cache engine won't insert the regular client/​browser ''​Cache-Control''​ header because it is not desired to let the browser or proxy cache the dynamic content. This would remove cache control from the server, and if LSCache no longer has control, it will be unable to purge updated content. As a result, the browser will serve out-of-date pages. 
 +  
 +''​x-litespeed-cache-control''​ is on our ADC to do list. 
  
 +If there is still a need to let the browser cache content, you can configure the backend to insert regular "​Cache-Control"​ headers.
 +   
 +{{ :​litespeed_wiki:​cache:​adc-cache-rewrite-max-control-header.png?​600 |}}
 ===== Turning On the Web ADC Debug Log ===== ===== Turning On the Web ADC Debug Log =====
 To turn on the Web ADC Debug Log, you would follow the exact same steps that are laid-out [[litespeed_wiki:​config:​toggle-debug-logging|here]] for LiteSpeed Web Server. To turn on the Web ADC Debug Log, you would follow the exact same steps that are laid-out [[litespeed_wiki:​config:​toggle-debug-logging|here]] for LiteSpeed Web Server.
  
  • Admin
  • Last modified: 2020/11/18 15:36
  • by Lisa Clarke