This is an old revision of the document!


LSCache + Joomla 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 with 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).

From the LSWS WebAdmin Console navigate to Server » Cache.

Under Cache Storage Settings, set Storage path to the directory you want to use to store cached objects.

For example:

  Storage Path: /tmp/diskcache

It is recommended that this directory be on a dedicated disk or disk array in RAID 0 configuration.

Note: You will need to create the desired directory before setting it as the Storage Path through the WebAdmin. Do this through the command line.

For example:

   mkdir /tmp/diskcache
   chown nobody:nobody /tmp/diskcache
   chmod 700 /tmp/diskcache

Under Cache Policy, we recommend using the following settings:

  Enable Cache:No
  Cache Request with Query String:Yes        
  Cache Request with Cookie:Yes
  Cache Response with Cookie:Yes        
  Ignore Request Cache-Control:Yes
  Ignore Response Cache-Control:Yes
  Enable Private Cache: No

Note: Enable Cache has been set to “No” globally as caching will instead be enabled through the use of rewrite rules to control what pages will be cached and for how long.

In your .htaccess file, located in the document root of your website, after the line

########## End - Rewrite rules to block out some common exploits

add the following:

########## Begin - Litespeed cache
<IfModule LiteSpeed>
RewriteEngine On
RewriteRule .* - [E=Cache-Control:max-age=120]
 
RewriteCond %{REQUEST_URI} ^/administrator/ [OR]
RewriteCond %{HTTP_HOST} ^admin.your_domain_name.com$ [NC]
RewriteRule .* - [E=Cache-Control:no-cache]
</IfModule>
########## End - Litespeed cache

Where “your_domain_name.com” is the web address of your Joomla site.

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.

Adding a cron job to delete outdated cache files

While optional, it is a good idea to clear out old cache files that are past the set Time To Live (TTL). To do this enter the following in /etc/crontab

/10 * * * * root find /tmp/diskcache -type f -mmin +8 -delete 2>/dev/null

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 that are way passed TTL.

  • Admin
  • Last modified: 2015/10/13 13:55
  • by Michael Alegre