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:cache:craftcms-lscache-purge-plugin [2018/05/10 15:09]
Jackson Zhang [I set rewrite rules according to the wiki, but why my admin pages being cached?]
litespeed_wiki:cache:craftcms-lscache-purge-plugin [2020/08/20 18:53] (current)
Lisa Clarke Redirect to new Documentation Site
Line 1: Line 1:
-====== LSCache + Craft CMS and Purge Cache Plugin Configuration ====== +~~REDIRECT>https://docs.litespeedtech.com/​lscache/​lsccc/overview/~~
- +
-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 Craft CMS, you can expect significant performance gains with a quick and easy setup. Cache management is also made significantly easier and more flexible. Rewrite rules can still be used to customize LSCache'​s behavior. +
- +
-Below are some recommended configurations to enable LSCache and get it working with your Craft CMS site(s). +
- +
-===== Configure Server/​Virtual Host Level Cache Root And Cache Policy ===== +
- +
-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. +
- +
-===== Rewrite 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> +
-        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 8 hours excluding ''/​admin''​ URLs  +
- +
-  ########## Begin - Litespeed cache +
-  <​IfModule LiteSpeed>​ +
-    RewriteEngine On +
-    RewriteCond %{REQUEST_METHOD} ^HEAD|GET$ +
-    RewriteCond %{ORG_REQ_URI} !/admin +
-    RewriteCond %{ORG_REQ_URI} !/​index.php/​admin ​    +
-    RewriteRule .* - [E=Cache-Control:max-age=28800] +
-  </IfModule>​ +
-  ########## End - Litespeed cache +
-  +
- +
-===== Verify Cache Setup ===== +
- +
-Open your browsers inspector, by right-clicking and selecting "​Inspector"​ or pressing the F12 key, and refresh the page. Under the "​Network"​ tab look for the HTML page you just loaded and clikc on it to view it's response header.  +
- +
-In the response header you should see ''​X-LiteSpeed-Cache:​ hit''​ to indicate that the page was served from cache successfully. If you see ''​X-LiteSpeed-Cache:​ miss'',​ reload the page and check again.  +
- +
-===== Purge Cache ===== +
- +
-This is 3rd Party plugin that will help you clear/purge LSCache. +
- +
-==== Requirements ==== +
- +
-Craft CMS version 3.0.0 or later +
- +
- +
-==== Installation ==== +
- +
-To install the plugin, search for LiteSpeed Cache on the Plugin store, or install manually with the following instructions:​ +
- +
-Open your terminal and go to your Craft project: +
- +
- <​code>​cd /​path/​to/​project</​code>​ +
- +
-Then tell Composer to require the plugin: +
- +
- <​code>​composer require thoughtfulweb/​lite-speed-cache</​code>​ +
- +
-In the Control Panel, go to Settings → Plugins and click the “Install” button for LiteSpeed Cache. +
- +
-==== Usage ==== +
- +
-**On Page Save** +
- +
-Choose whether or not to clear caches by URL, and set the directory where your LSCache folder is located in the plugin settings. If you do not select the per-URL option, all of the cached content in the LSCache folder will be removed on every page save. +
- +
-**Manually** +
- +
-If you just want to nuke the whole cache folder at once, you can go opt to Force Clear LiteSpeed Cache in the plugins CP section. Clicking the clear button will remove all of the cached content in the LSCache folder. +
- +
-We recommend checking the [[https://​github.com/thoughtfulweb/​craft-litespeedcache|Github]] page for example. +
- +
- +
-===== 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=28800] +
-  </​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: 2018/05/10 15:09
  • by Jackson Zhang