Litespeed cache not obeying .htaccess rules

#1
Hi,

Currently I have LiteSpeed setup with a globally enabled private cache. Enable Cache is set to no.

I've tried adding the following things to my .htaccess so that the globally enabled private cache is disabled on the site:

CacheDisable
CacheDisable private
RewriteRule (.*) - [E=Cache-Control:no-cache]

None of the above in any configuration appears to change the behavior and I have confirmed that the cache IS being used (using the realtime stats of in the LiteSpeed control panel).

This is all my cache settings: http://d.pr/i/yX35

If it makes any difference I'm running CageFS with PHP Selector, but the same behavior happens with users having CageFS disabled.

Any advice please?

Edit: Sorry, didn't see the dedicated forum for the cache, mods please feel free to move this post (I can't do it myself I'm afraid).
 
Last edited:

mistwang

LiteSpeed Staff
#2
You have to put "CacheDisable private" in the corresponding <VirtualHost ...> configuration section of httpd.conf.

private cache was processed before .htaccess.
 
#3
You have to put "CacheDisable private" in the corresponding <VirtualHost ...> configuration section of httpd.conf.

private cache was processed before .htaccess.
So what you're saying is that if private cache is globally enabled there is no way to disable it via .htaccess?
 
#7
Okay thanks.

I just attempted with a new file, and confirmed that it works, but only with
RewriteRule (.*) - [E=Cache-Control:no-cache]

CacheDisable and CacheDisable private I couldn't seem to get to work for some reason.
 
Last edited:

Sindre

Well-Known Member
#8
you need to purge the private cache copy if it still valid. document is updated accordingly.
Question 1: how do you purge the private cache copy?
Question 2: how exactly does the EnableCache/DisableCache directives work with regard to .htaccess? Obviously it does not work to disable it through .htaccess if it is enabled globally, but it does not work to enable it through .htaccess if it is globally disabled either? Could need some clarification here.
 

NiteWave

Administrator
#9
Sorry for reply late. today have time to test with private cache following this thread.

>Question 1: how do you purge the private cache copy?
same way to purge public cache. both public and private cache have a common cache root.
the easy way to purge cache is
1)delete all sub folders / files under cache root
2)assume cache folder is /lswscache, minimum cache time is 3 minutes
#find /lswscache -type f -mmin +3 -delete
will delete all caches which modified(updated) 3 minutes ago.

>but it does not work to enable it through .htaccess if it is globally disabled either? Could need some clarification here.
did tests --- can enable private cache for particular URL if disabled globally.
 

Sindre

Well-Known Member
#10
Sorry for reply late. today have time to test with private cache following this thread.

>Question 1: how do you purge the private cache copy?
same way to purge public cache. both public and private cache have a common cache root.
the easy way to purge cache is
1)delete all sub folders / files under cache root
2)assume cache folder is /lswscache, minimum cache time is 3 minutes
#find /lswscache -type f -mmin +3 -delete
will delete all caches which modified(updated) 3 minutes ago.

>but it does not work to enable it through .htaccess if it is globally disabled either? Could need some clarification here.
did tests --- can enable private cache for particular URL if disabled globally.
So what you are saying is that you can have all cache disabled globally in config, and still enable it for particular url/site through CacheEnable private in .htaccess? In other words, the .htaccess overrides only works to enable a globally disabled cache, but not the other way around?
 
#11
So what you are saying is that you can have all cache disabled globally in config, and still enable it for particular url/site through CacheEnable private in .htaccess?
yes. through
Code:
CacheEnable private
or 
RewriteRule /a-b-c-d.php - [E=Cache-Control:private]
or
RewriteRule /a-b-c-d.php - [E=Cache-Control:max-age=60]  #for public cache
also disable particular URL's public cache by
Code:
RewriteRule /a-b-c.php - [E=Cache-Control:no-cache]
and not possible to disable private cache for particular URL if private cache enabled globally.
 
Top