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
litespeed_wiki:litespeed:cache [2014/06/10 20:07]
George Wang
litespeed_wiki:litespeed:cache [2017/01/03 19:56] (current)
Michael Alegre Added Redirect.
Line 1: Line 1:
-====== Introduction ======+~~REDIRECT>​litespeed_wiki:​cache:​lscache~~ 
 + 
 +====== ​LiteSpeed Cache (LSCache) ​Introduction ======
    
-LiteSpeed has made a built-in cache functionality (an advanced feature for Enterprise 2+CPU license) available ​since version 4.0 (March, 2009), ​and keeps improving throughout the later 4.0.x releases ​and 4.1RC releases. As of 4.1.1 (May, 2011), private cache support is added.+LiteSpeed has created ​a built-in cache functionality (an advanced feature for Enterprise 2+CPU license. Available ​since version 4.0 (March, 2009), ​its performance ​keeps improving throughout the later 4.0.x and 4.1RC releases. As of 4.1.1 (May, 2011), private cache support is added.
  
-LiteSpeed cache has similar ​features ​as Apache mod_cache but implemented in a more efficient way, and works like Varnish. It is an output cache for dynamic contents, so the usage does not limit to PHP pages. Unlike Varnish, ​it is built into LiteSpeed web server, eliminating one layer of reverse proxy. ​Hence more efficient ​for static contents. The uniqueness of LiteSpeed cache is that it uses rewrite rules (either in configuration files or .htaccess) to control its behavior for maximum flexibility. ​+LiteSpeed'​s ​cache features ​are very similar to those in Apache mod_cachebut implemented in a more efficient way. LiteSpeed cache works like Varnish. It is an output cache for dynamic contents, so the usage is not limited ​to PHP pages. Unlike Varnish, ​LiteSpeed cache is built into LiteSpeed'​s ​web server, ​thus eliminating one layer of reverse proxy. ​This translates into higher efficieny ​for static contents. The uniqueness of LiteSpeed cache is that it uses rewrite rules (either in configuration files or .htaccess) to control its behavior for maximum flexibility. ​
  
-A general way to enable LiteSpeed Cache through rewrite rules is to designate a signature token (such as cookie) in a page (or any pagein most cases to tell LSWS that cache can be enabled and TTL(Time To Live) of the cache freshness ​however ​acceptable. Generating ​cookie ​usually requires application code modification. ​Refer to [[http://​www.litespeedtech.com/​support/​forum/​showthread.php?​t=4679]] for example. It is worth noting that the cache function **SHOULD ONLY** be used for the pages that are **supposed to be cached or cache friendly**. Abuse use of this feature would result in performance degradation and/or other unexpectancies.+A general way to enable LiteSpeed Cache through rewrite rules is to designate a signature token (such as cookie) in any pagein most cases it will tell LSWS that cache can be enabled and that the TTL(Time To Live) of the cache freshness ​will remain ​acceptable. Generating ​cookies ​usually requires application code modification. ​Please refer to [[http://​www.litespeedtech.com/​support/​forum/​showthread.php?​t=4679]] for examples. It is worth noting that the cache function **SHOULD ONLY** be used for pages that are **supposed to be cached or cache friendly**. Abuse use of this feature would result in performance degradation and/or other unexpectancies.
  
-Since 4.1.1 (May, 2011), private cache support ​is added. Private cache is for caching resources for individual specifically instead of public shared. The purposes are:+Since 4.1.1 (May, 2011), private cache support ​has been added. Private cache is for caching resources for individual specifically instead of public shared. The purposes are:
   * maintain a persistent cache for applications that do not have a shared cache.   * maintain a persistent cache for applications that do not have a shared cache.
   * maintain a private persistent cache for specific groups of documents that are not to be shared among other applications.   * maintain a private persistent cache for specific groups of documents that are not to be shared among other applications.
Line 45: Line 47:
 ====== How to enable LiteSpeed Cache ====== ====== How to enable LiteSpeed Cache ======
  
-Here are the steps to enable LSWS built-in cache:+Although there is a advanced setting [[http://​litespeedtech.com/​docs/​webserver/​config/​cache#​cachePolicy:​enableCache|"​Enable Cache"​]] ​ in LSWS Wed Admin Console on both server and virtual host level, "​No"​ is always recommended since globally enabled public cache may cause problem when URLs change or other changes on the domain. We recommend to enable cache through rewrite rules. ​Here are the steps to enable LSWS built-in cache:
  
 **1. Enable cache function at Server level in LSWS** **1. Enable cache function at Server level in LSWS**
Line 77: Line 79:
 **3. For imported Apache vhost:** **3. For imported Apache vhost:**
 Cache can be turned on/off with "​CacheEnable"​ , "​CacheDisable"​ directives in Apache config file: .htaccess (preferred) or httpd.conf, etc. Nothing needs to be done for the cache policy. It will assume the same default settings at LSWS Server level. ​ Cache can be turned on/off with "​CacheEnable"​ , "​CacheDisable"​ directives in Apache config file: .htaccess (preferred) or httpd.conf, etc. Nothing needs to be done for the cache policy. It will assume the same default settings at LSWS Server level. ​
-  ​To enable private cache, you can add to .htaccess under document root of the web site,+  ​To enable private cache, you can add to .htaccess under document root of the web site,
  
   <​IfModule LiteSpeed> ​   <​IfModule LiteSpeed> ​
Line 83: Line 85:
   </​IfModule> ​   </​IfModule> ​
  
-  ​To disable private cache, ​+  ​To disable private cache, ​
  
   <​IfModule LiteSpeed> ​   <​IfModule LiteSpeed> ​
Line 89: Line 91:
   </​IfModule> ​   </​IfModule> ​
  
-  ​To enable public cache,+  ​To enable public cache,
  
   <​IfModule LiteSpeed> ​   <​IfModule LiteSpeed> ​
Line 95: Line 97:
   </​IfModule> ​   </​IfModule> ​
  
-  ​To disable public cache,+  ​To disable public cache,
  
   <​IfModule LiteSpeed> ​   <​IfModule LiteSpeed> ​
Line 170: Line 172:
  
 Since 4.1.1 release, LiteSpeed outputs a response header “X-LiteSpeed-Cache:​ hit,​private” if a request is served from private cache. Since 4.1.1 release, LiteSpeed outputs a response header “X-LiteSpeed-Cache:​ hit,​private” if a request is served from private cache.
 +
 +**Note:** LSCache hit rate is calculated based on all files served. Many of the files served by LSWS, like CSS or HTML, are intentionally not cached by LSCache. Because these files are included in the LSCache hit rate calculation,​ the hit rate may sometimes look much lower than one might expect.
  
 **8. Cache clean up (Optional)** **8. Cache clean up (Optional)**
  • Admin
  • Last modified: 2014/06/10 20:07
  • by George Wang