This is an old revision of the document!


How to disable cache globally but enable for a particular virtual host on shared hosting environment?

Shared hosting provider may want to have more control on cache on/off, esi on/off, crawler on/off (esi and crawler are only applied to WordPress cache plugin at the time of this writing). This way, shared hosting provider provide lscache as an add on services to their customer. You can use the following directives to disable cache on a global level, such as cpanel's pre_main_global, and enable it on virtual host include file ( but not .htaccess) to enable it individually.

To disable cache:

CacheEngine off

To enable cache, esi and crawler:

CacheEngine on esi crawler

To enable cache, but neither esi nor crawler:

CacheEngine on

The directives should be placed within <IfModule Litespeed> .. </IfModule>, could be right after the CacheRoot configurations.

For example for cPanel server, to disable cache globally: Add the above to the /usr/local/apache/conf/includes/pre_main_global.conf file for EA3 or the /etc/apache2/conf.d/includes/pre_main_global.conf file for EA4

<IfModule Litespeed>
CacheRoot /home/lscache/
CacheEngine off
</IfModule>

then enable it in a particular virtual host:

Example: Apache 2.2 installations with an HTTP site

Create a file named lscache_vhost.conf in the /usr/local/apache/conf/userdata/std/2_2/<user>/<domain>/ directory for EA3 or /etc/apache2/conf.d/userdata/a/std/2_2/<user>/<domain>/ directory for EA4 (if this directory does not exist, create it) with the following lines:

<IfModule Litespeed>
CacheRoot lscache
CacheEngine on esi crawler
</IfModule>

This will set the cache directory for this Virtual Host to /home/<user>/lscache.

Apply these changes to this Virtual Host by running the ensure_vhost_includes script with the following flag:

/scripts/ensure_vhost_includes --user=$user

For HTTPS sites or Apache 2.4 installations, please refer to cPanel's documentation on modifying virtual host containers with include files.

If you use other control panels, you should be able to use the similar directives to control the cache for your shared hosting accounts.

Enabling crawler is applicable for LiteSpeed WordPress plugin at the time of this writing and may be expanded to other application support when these LiteSpeed cache plugins become available.

For details on how to enable crawler, pleaser refer to How to enable crawler for WordPress

  • Admin
  • Last modified: 2017/09/11 15:36
  • by Jackson Zhang