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:no-plugin-drupal-7 [2017/04/11 13:46]
Johathan Kagan [Website Level Settings]
litespeed_wiki:cache:no-plugin-drupal-7 [2017/05/10 20:07]
Jackson Zhang removed
Line 1: Line 1:
-====== LSCache + Drupal ​Configuration ======+====== LSCache + Drupal Configuration ======
  
-LSCache, similar to Varnish cache, is a simpler and more efficient page caching solution built-in to LiteSpeed Web Server. When used in conjunction with Drupal ​7, you can expect significant performance gains with a quick and easy setup. Cache management is also made significantly easier and more flexible with the ability to use rewrite rules to customize cache behavior.+LSCache, similar to Varnish cache, is a simpler and more efficient page caching solution built-in to LiteSpeed Web Server. When used in conjunction with Drupal, you can expect significant performance gains with a quick and easy setup. Cache management is also made significantly easier and more flexible with the ability to use rewrite rules to customize cache behavior.
  
-Below are some recommended configurations to enable LSCache and get it working with your Drupal ​site(s).+Below are some recommended configurations to enable LSCache and get it working with your Drupal site(s).
  
 +===== Configure Server/​Virtual Host Level Cache Root And Cache Policy =====
  
-===== Server ​Level Settings =====+Server/​VirtualHost level cache storage needs to be configured properly for your environment. Select your server setup from the **Web Server Configuration** section of our **[[litespeed_wiki:​cache:​common_installation#​web_server_configuration|LiteSpeed Cache Installation Guide]]** and follow the instructions to set the server/​virtual host level cache root and cache policy.
  
-From the LSWS WebAdmin Console navigate to **Server >> Cache**. 
  
-Under **Cache Storage Settings**, set **Storage path** to the directory you want to use to store cached objects. +===== Rewrite rules =====
- +
-For example: +
- +
-    Storage Path: /​tmp/​diskcache +
- +
-It is recommended that this directory be on a dedicated disk or disk array in RAID 0 configuration. +
- +
-Under **Cache Policy**, we recommend using the following settings: +
- +
-    Enable Cache:No +
-    Cache Request with Query String:​Yes ​        +
-    Cache Request with Cookie:​Yes +
-    Cache Response with Cookie:​Yes ​        +
-    Ignore Request Cache-Control:​Yes +
-    Ignore Response Cache-Control:​Yes +
-    Enable Private Cache: No +
- +
-**Note:** **Enable Cache** has been set to “No” globally as caching will instead be enabled through the use of rewrite rules to control what pages will be cached and for how long. +
- +
-===== Website Level Settings ​=====+
  
 At the top of your .htaccess file, located in the document root of your website, add the following: At the top of your .htaccess file, located in the document root of your website, add the following:
Line 36: Line 16:
   ########## Begin - Litespeed cache   ########## Begin - Litespeed cache
   <​IfModule LiteSpeed>​   <​IfModule LiteSpeed>​
-    ​CacheLookup ​public ​on+    ​CacheDisable ​public ​/
     RewriteEngine On  ​     RewriteEngine On  ​
     RewriteCond %{REQUEST_METHOD} ^GET|HEAD|PURGE$     RewriteCond %{REQUEST_METHOD} ^GET|HEAD|PURGE$
-    RewriteCond %{HTTP_HOST} ^your_domain_name.com [NC]+    RewriteCond %{HTTP_HOST} ^(www.)?your_domain_name.com [NC]
     RewriteCond %{REQUEST_URI} !admin|register|login [NC]     RewriteCond %{REQUEST_URI} !admin|register|login [NC]
     RewriteCond %{HTTP_COOKIE} !SESS [NC]     RewriteCond %{HTTP_COOKIE} !SESS [NC]
Line 46: Line 26:
   </​IfModule>​   </​IfModule>​
   ########## End - Litespeed cache   ########## End - Litespeed cache
-  ​ 
-Where "​your_domain_name.com"​ is the web address of your Drupal 7 site.  ​ 
  
-We recommend using a different domain for your backend so that you can add/​edit/​preview a website'​s content through the admin domain without worrying about these changes being cached and seen by visitors.+**Note1:​** ​ The **"​CacheDisable public /"** directive is used to help protect against globally enabled caching and is optional. Instead, the server'​s global cache settings should be checked to ensure that cache is not enabled globally. **Do NOT** use **"​CacheEnable public /"** here as it will enable caching for all URLs belonging to this virtual host, including admin pages. 
 + 
 +  
 +**Note2:** Where "​your_domain_name.com"​ is the web address of your Drupal site.   
 + 
 +**Note3:​** ​We recommend using a different domain for your backend so that you can add/​edit/​preview a website'​s content through the admin domain without worrying about these changes being cached and seen by visitors.
  
-To get the non-cached version of a page, add the "​nocache"​ query string to a URL.+**Note4:​** ​To get the non-cached version of a page, add the "​nocache"​ query string to a URL.
  
 For example For example
Line 58: Line 41:
   https://​www.your_domain_name.com/​about?​some_other_query_string&​nocache   https://​www.your_domain_name.com/​about?​some_other_query_string&​nocache
  
-===== Discussion ​===== +===== Verify Cache Setup =====
-__**Adding a cron job to delete outdated cache files**__+
  
-While optional, it is a good idea to clear out old cache files that are past the set **Time To Live (TTL)**. To do this enter the following in /​etc/​crontab+Please verify ​to see if you can see "​X-LiteSpeed-Cache:​ hit" by following [[litespeed_wiki:​cache:​no-plugin-setup-guidline#​verify_that_pages_are_served_from_the_cache|this wiki]].
  
-  /10 * * * * root find /​tmp/​diskcache -type f -mmin +8 -delete 2>/​dev/​null+===== Deleting Outdated Cache Files Using A Cron Job =====
  
-**Note:** This cron job deletes cached files that are more than 8 minutes old every 10 minutes. Since the cache TTL is set at 120 seconds (2 minutes), it is safe to delete these files that are way passed TTL.+Please refer to [[litespeed_wiki:cache:​no-plugin-setup-guidline#​deleting_outdated_cache_files_using_a_cron_job|this wiki]].
  • Admin
  • Last modified: 2020/12/08 16:55
  • by Lisa Clarke