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:no-plugin-joomla [2017/03/30 16:33]
Jackson Zhang [Adding a cron job to delete outdated cache files]
litespeed_wiki:cache:no-plugin-joomla [2020/09/17 19:49] (current)
Lisa Clarke Redirect to new Documentation Site
Line 1: Line 1:
-====== LSCache + Joomla Configuration ====== +~~REDIRECT>https://docs-stage.ls.com/20200902-lscache/lscache/noplugin/settings/~~
- +
-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 Joomla, you can expect significant performance gains with a quick and easy setup. Cache management is also made significantly easier and more flexible. While Litespeed cache plugin for Joomla is still in development,​ user has the ability to use rewrite rules to customize LSCache'​s behavior. +
- +
-Below are some recommended configurations to enable LSCache and get it working with your Joomla site(s). +
- +
- +
-===== Configure Server and 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 in the **Set Server/​VirtualHost Level Cache Root and cache policy** section of your respective guide. +
-===== Website Level Settings ===== +
- +
-In your .htaccess file, located in the document root of your website, add rewrite rules right before the line: +
-   +
-  ## Begin - Joomla! core SEF Section. +
- +
-==== Case 1: Cache all URLs excluing /​administrator URLs for 2 mins:==== +
- +
- +
-  ########## Begin - Litespeed cache +
-  <​IfModule LiteSpeed> +
-    RewriteEngine On +
-    CacheDisable public / +
-    RewriteCond %{REQUEST_METHOD} ^HEAD|GET$ +
-    RewriteCond %{ORG_REQ_URI} !/​administrator +
-    RewriteRule .* - [E=Cache-Control:max-age=120] +
-  </IfModule>​ +
-  ########## End - Litespeed cache +
-  +
-**Note:​** ​ "​CacheDisable public ​/" directive is optional. It is to prevent any global cache enabling mistake. Normally you should check server global settings to avoid any global cache enabling.  +
-Do not use "​CacheEnable public /" here since it will enable cache for all URLs of this virtual host, instead, rewrite rules will enable the cache for you. +
- +
-==== Case 2: Cache all URLs but specify non cache URLs  ==== +
- +
-  ########## Begin Litespeed cache +
-  <​IfModule LiteSpeed>​ +
-    RewriteEngine On +
-    CacheEnable public / +
-    RewriteCond %{REQUEST_METHOD} ^HEAD|GET$ +
-    RewriteCond %{ORG_REQ_URI} /​administrator/​ +
-    RewriteRule ​.* - [E=Cache-Control:​no-cache] +
-  </​IfModule>​ +
-  ########## End - Litespeed cache +
-   +
-==== Case 3: Specify which domain to be cached, which domain not  ==== +
- +
-  ########## Begin - Litespeed cache +
-  <​IfModule LiteSpeed>​ +
-   ​RewriteEngine On +
-   ​RewriteCond %{REQUEST_METHOD} ^HEAD|GET$ +
-   ​RewriteCond %{HTTP_HOST} ^domain.com [NC] [OR] +
-   ​RewriteCond %{HTTP_HOST} ^www.domain.com [NC] +
-   ​RewriteCond %{ORG_REQ_URI} !/administrator +
-   ​RewriteRule .* [E=Cache-Control:​max-age=120] +
-  </​IfModule>​ +
- +
-**Note:** 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. For example: admin.domain.com for admin user, domain.com, and www.domain.com for general public. You can specify which domain to be cached, such as domain.com and www.domain.com,​ then admin.domain.com won't be cached. ​  +
- +
-===== Test: Verify if cahce setup is correct ===== +
- You should see "​X-LiteSpeed-Cache:​ hit" in your URL. If you see "​X-LiteSpeed-Cache:​ miss", reload the page again.  +
- +
-===== Adding a cron job to delete outdated cache files ===== +
-Set cron job to clear out old cache files that are past the set **Time To Live (TTL)**.  +
- +
-To do this, you should run the crontab either by root user or shared hosting account user. Shared hosting account user can manage cache by himself. +
- +
-<​code>​crontab -e</​code>​ +
- +
-Normally **/​virtualhost/​cache/​root/​directory/​** is at **/​home/​$USER/lscache** for shared hosting user or simply as **/tmp/diskspace** for dedicated server. +
- +
-<​code>​*/10 * * * * root find /​virtualhost/​cache/​root/​directory/​ -type f -mmin +8 -delete 2>/​dev/​null</​code>​ +
- +
-**Note1:** 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. +
- +
-**Note2:** This is optional since lsws will delete expried cache automatically. This cron job can ensure cache work as expected. For example, due to some wrong configurations,​ some pages may have been set very long expiration time. The cron job above will ensure old cache deleted.+
  • Admin
  • Last modified: 2017/03/30 16:33
  • by Jackson Zhang