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:no-plugin-joomla [2017/03/30 16:30]
Jackson Zhang [Adding a cron job to delete outdated cache files]
litespeed_wiki:cache:no-plugin-joomla [2018/03/22 14:34]
Lisa Clarke [LSCache + Joomla (<3.x) Configuration] Proofreading
Line 1: Line 1:
-====== LSCache + Joomla Configuration ======+====== LSCache + Joomla ​(<​3.x) ​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 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.+**NOTE: [[litespeed_wiki:​cache:​lscjoomla|There is a module now]]. If you are running Joomla 3.x or later, please use the module. If you are running Joomla 2.x or lower, you can still use the rewrite-rule-based LSCache as instructed in this wiki. ** 
 + 
 +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 the LiteSpeed ​cache plugin for Joomla is still in development,​ 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 Joomla site(s). Below are some recommended configurations to enable LSCache and get it working with your Joomla 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.
  
-===== Configure Server and Virtual Host Level Cache Root and Cache policy ===== +===== Rewrite rules =====
-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:+Rewrite rules should be added to your .htaccess file, located in the document root of your website, right before the following ​line:
   ​   ​
   ## Begin - Joomla! core SEF Section.   ## Begin - Joomla! core SEF Section.
  
-==== Case 1: Cache all URLs excluing /​administrator ​URLs for 2 mins:==== +==== Case 1: Cache all URLs for 2 mins excluding ''/​administrator''​ URLs ====
- +
   ########## Begin - Litespeed cache   ########## Begin - Litespeed cache
   <​IfModule LiteSpeed>​   <​IfModule LiteSpeed>​
Line 27: Line 28:
   ########## End - Litespeed cache   ########## 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.  +**Note:​**  ​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 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  ​====+**Note:** Do not use ''​CacheEnable public /''​ here as it will enable caching for all URLs belonging to this virtual host, including admin pages. 
 + 
 +==== Case 2: Caching ​all URLs except those specified ​====
  
   ########## Begin - Litespeed cache   ########## Begin - Litespeed cache
Line 42: Line 44:
   ########## End - Litespeed cache   ########## End - Litespeed cache
   ​   ​
-==== Case 3: Specify which domain to be cached, which domain not  ​====+==== Case 3: Caching URLs for specified domains only ====
  
   ########## Begin - Litespeed cache   ########## Begin - Litespeed cache
Line 54: Line 56:
   </​IfModule>​   </​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.comand 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.  ​ +**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 users, domain.com and www.domain.com for the general public. You can specify which domain to be cached, such as domain.com and www.domain.com, ​so that 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>​+===== Verify Cache Setup =====
  
-**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.+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]].
  
-**Note2:** This is optional. while lsws will delete expried cache automatically,​ this cron job can ensure or help cache work as expected. for example, because of a wrong configuration,​ some pages has been set very long expiration time. this cron job will ensure old cache is deleted and clean up the disk space.+===== Deleting Outdated Cache Files Using A Cron Job =====
  
 +Please refer to [[litespeed_wiki:​cache:​no-plugin-setup-guidline#​deleting_outdated_cache_files_using_a_cron_job|this wiki]].
  • Admin
  • Last modified: 2020/09/17 19:49
  • by Lisa Clarke