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
Last revision Both sides next 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 [2018/05/24 14:26]
Lisa Clarke [Purge Cache] added link to developer
Line 1: Line 1:
-====== LSCache + Craft CMS and Purge Cache Plugin ​Configuration ​======+====== LSCache + Craft CMS and the Purge Cache Plugin ======
  
-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.+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. Rewrite rules can 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).+With the addition of the 3rd party "Purge Cache" plugin, cache management is made even more flexible, allowing you to set longer TTLs for your content. 
 + 
 +Learn how to enable LSCache ​and the Purge Plugin, ​and get them working with your Craft CMS site(s) ​below.
  
 ===== Configure Server/​Virtual Host Level Cache Root And Cache Policy ===== ===== 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.+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 =====
Line 20: Line 22:
         RewriteRule (.+) index.php?​p=$1 [QSA,L]         RewriteRule (.+) index.php?​p=$1 [QSA,L]
   </​IfModule>​   </​IfModule>​
-Place rewrite ​ruls on the top of the existing rules to cache all URLs for 8 hours excluding ​''/​admin''​ URLs +Place rewrite ​rules above the existing rules to cache all URLs. The following rules will cache all pages for 8 hours (28800 seconds) with the exception of ''/​admin''​ URLs:
  
   ########## Begin - Litespeed cache   ########## Begin - Litespeed cache
Line 35: Line 37:
 ===== Verify Cache Setup ===== ===== Verify Cache Setup =====
  
-Open your browsers ​inspectorby 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. ​+Open your browser'​s ​inspector by right-clicking and selecting "​Inspector"​ or by pressing the F12 key, and refresh the page. Under the "​Network"​ tab look for the HTML page you just loaded and click on it to view its 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. ​ 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. ​
Line 41: Line 43:
 ===== Purge Cache ===== ===== Purge Cache =====
  
-This is 3rd Party plugin ​that will help you clear/purge LSCache.+The ability to configure an LSCache purge allows you to specify longer caching periods for your content. For example, you can confidently set ''​max-age''​ to several hours, if you know that pages will be automatically cleared from cache if they are changed in the CMS. The ability to purge the cache eliminates the fear of serving stale content. 
 + 
 +This is 3rd Party plugin. Our thanks to [[https://github.com/​thoughtfulweb/​craft-litespeedcache|Thoughtful]],​ the developer! ​
  
 ==== Requirements ==== ==== Requirements ====
  
 Craft CMS version 3.0.0 or later Craft CMS version 3.0.0 or later
- 
  
 ==== Installation ==== ==== Installation ====
Line 54: Line 57:
 Open your terminal and go to your Craft project: Open your terminal and go to your Craft project:
  
- <​code>​cd /​path/​to/​project</​code>​+  ​cd /​path/​to/​project
  
 Then tell Composer to require the plugin: Then tell Composer to require the plugin:
  
- <​code>​composer require thoughtfulweb/​lite-speed-cache</​code>​+  ​composer require thoughtfulweb/​lite-speed-cache
  
 In the Control Panel, go to Settings → Plugins and click the “Install” button for LiteSpeed Cache. In the Control Panel, go to Settings → Plugins and click the “Install” button for LiteSpeed Cache.
Line 64: Line 67:
 ==== Usage ==== ==== Usage ====
  
-**On Page Save**+There are two ways to purge the cache. You can configure it to purge automatically when pages are saved in the CMS, or you can press a button to purge the entire cache at once. 
 + 
 +===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. 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**+===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.+If you just want to purge the entire ​cache folder at once, you can Navigate ​to **Force Clear LiteSpeed Cache** in the plugin'​s ​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.+We recommend checking the [[https://​github.com/​thoughtfulweb/​craft-litespeedcache|Github ​page]] for examples.
  
  
 ===== Troubleshooting ===== ===== Troubleshooting =====
-==== I set rewrite rules according to the wiki, but why my admin pages being cached==== +==== I set rewrite rules according to the wiki, but my admin pages are cached ​anyway ​==== 
- 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.+ LSCache ​could be incorrectly enabled ​globally at the server level. You can either correct ​this by setting "​Enable Public Cache" to "not set" or "​no"​ according to [[litespeed_wiki:​cache:​common_installation#​web_server_configuration|this recommendations]],​ or you can disable ​the global setting for a particular virtual host in .htaccess first before the rewrite rules, like so:
  
   ########## Begin - Litespeed cache   ########## Begin - Litespeed cache
Line 90: Line 95:
   ########## End - Litespeed cache   ########## End - Litespeed cache
  
-Note: The "CacheDisable public /" ​directive is used to help protect against globally enabled caching. The Rewrite ​rules will enable ​cache.+Note: The ''​CacheDisable public /'' ​directive is used to help protect against globally enabled caching. The rewrite ​rules will enable ​caching for your site.
  
  • Admin
  • Last modified: 2020/08/20 18:53
  • by Lisa Clarke