"Ignore Response Cache-Control" as .htaccess directive?

#1
Hi,

is there an .htaccess directive which mirrors the "Ignore Response Cache-Control: No" setting?

I am end user of a webspace hosting service and do not have access to LiteSpeed's configuration. The server seems to be set to "Ignore Response Cache-Control: Yes" and I need to set it to "No". My .php scripts calculate and output expiry times (from 5 minutes to 1 day) which LiteSpeed's cache ignores.

Thanks!
 
#2
Or is there another way to make LSCache respect the "Expires" header? Right now, LSCache still insists it is a cache "hit" when "Expires" is literally hours in the past.
 

serpent_driver

Well-Known Member
#3
Is it possible that you are confusing browser cache and server cache? The Expire header controls the browser cache, but not the server cache.
 
#4
I need a public cache, i.e. the same php script can be accessed by different users. The output is the same for all users (no cookie/login required) from a certain time t1 up to a time t2. So the scripts sets time t2 as the "Expires" header. This way I avoid executing the script too often by the same user. But making use of the server cache would be even more beneficial, right?
 

AndreyPopov

Well-Known Member
#5
@blubbb LSCache store dynamic generated by php page as static HTML page.
LSCache not cache php script.
if php script request same url for users then LSCache provide saved static HTML page from cache.

if you want provide to each user it's own version of url then you must enable private cache and use "Different View for signing users"
that generate lscache with lscache_vary/user cookies or by rewrite rules in .htaccess

or decrease LSCache public cache TTL to differences t2-t1
 
Last edited:
#6
The same URL typed in by different users results in the same output (until time t2), yes. This is why I want the server to cache this static output (until time t2).

My backup plan is to modify the script to save the output by itself and serve that saved copy until time t2 arrives. But I thought LSCache was built to do exactly this...
 
#8
But the .php script is not executed during the caching time!? How can it send a purge command?

Wouldn't it be easier if LSCache just took the "Expires" header as input?

Currently, I am reading
https://docs.litespeedtech.com/lscache/devguide/controls/#cachemaxexpire

Cache a response in private cache for a day:
X-LiteSpeed-Cache-Control: private,max-age=864020
Maybe this is the solution. But what unit is that? Cannot be seconds. Or the manual is wrong.
 

AndreyPopov

Well-Known Member
#9
Maybe this is the solution. But what unit is that? Cannot be seconds. Or the manual is wrong.
seconds.

yes, in manual mistype - 1 day is 86400 seconds (not 864020)

but may be you need
X-LiteSpeed-Cache-Control: public,max-age=86400


manual again have mistype, because by default public cache TTL greater than private cache TTL
and because by default: CacheMaxExpire 604800 - one week
 
Last edited:
#10
X-LiteSpeed-Cache-Control seems to work.

But
example.php?a=1&b=1
and
example.php?b=1&a=1
are not seen as equivalent. Is this correct?
 

serpent_driver

Well-Known Member
#11
@blubbb
You should study the documentation because you seem to have a fundamental misunderstanding about LScache. Also, you don't seem to understand the basic difference between browser cache and server cache. This forum will be happy to help you, but you need a basic knowledge of LScache. Otherwise you will get wrong answers to wrong questions.
 
Top