Differences

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

Link to this comparison view

Next revision
Previous revision
litespeed_wiki:cache:no-plugin-craft [2017/04/13 17:49]
Jackson Zhang created
litespeed_wiki:cache:no-plugin-craft [2018/05/15 20:39] (current)
Jackson Zhang old revision restored (2017/04/14 13:28)
Line 11: Line 11:
 ===== Rewrite rules ===== ===== Rewrite rules =====
  
-Rewrite rules should be added to your .htaccess file, located in the document root of your website, on the top of the existing rules+Rewrite rules should be added to your .htaccess file, located in the document root of your website. It may contain the following:  
- +  <​IfModule mod_rewrite.c>​ 
-==== Cache all URLs for 2 mins excluding ''/​admin''​ URLs ====+        RewriteEngine On 
 +        # Send would-be 404 requests to Craft 
 +        RewriteCond %{REQUEST_FILENAME} !-f 
 +        RewriteCond %{REQUEST_FILENAME} !-d 
 +        RewriteCond %{REQUEST_URI} !^/​(favicon\.ico|apple-touch-icon.*\.png)$ [NC] 
 +        RewriteRule (.+) index.php?​p=$1 [QSA,L] 
 +  </​IfModule>​ 
 +Place rewrite ruls on the top of the existing rules to cache all URLs for 2 mins excluding ''/​admin''​ URLs 
  
   ########## Begin - Litespeed cache   ########## Begin - Litespeed cache
Line 47: Line 54:
  
 **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 as they are way past their TTL. **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 as they are way past their TTL.
 +
 +===== Troubleshooting =====
 +==== I set rewrite rules according to the wiki, but why my admin pages being cached? ====
 + The lscache could be incorrectly enabled on server level globally. You can either correct the wrong lscache setting "​Enable Public Cache" to "not set" or "​no"​ according to [[litespeed_wiki:​cache:​common_installation#​web_server_configuration|this recommendations]],​ or just disable global setting for a particular virtual host in .htaccess first before the rewrite rules.
 +
 +  ########## Begin - Litespeed cache
 +  <​IfModule LiteSpeed>​
 +   ​RewriteEngine On
 +   ​CacheDisable public /
 +   ​RewriteCond %{REQUEST_METHOD} ^HEAD|GET$
 +   ​RewriteCond %{ORG_REQ_URI} !/admin
 +   ​RewriteCond %{ORG_REQ_URI} !/​index.php/​admin ​   ​
 +   ​RewriteRule .* - [E=Cache-Control:​max-age=120]
 +  </​IfModule>​
 +  ########## End - Litespeed cache
 +
 +Note: The "​CacheDisable public /" directive is used to help protect against globally enabled caching. The Rewrite rules will enable cache.
 +
  • Admin
  • Last modified: 2017/04/13 17:49
  • by Jackson Zhang