Private cache max-age ?

Monarobase

Well-Known Member
#1
Hello,

Your wiki says to use E=Cache-Control:max-age=60 for 60 seconds public cache and E=Cache-Control:private for private cache.

Both of these work with .htaccess and mod_rewrite rules

Can I set the max-age for private cache in htacess files ?

Or can users only use the server global defined private cache max-age value ?

Thanks
 

NiteWave

Administrator
#4
for example, in .htaccess,
Code:
RewriteRule \.php - [E=Cache-Control:private,E=Cache-Control:max-age=300]
or
Code:
RewriteRule \.php - [E=Cache-Control:private]
RewriteRule \.php - [E=Cache-Control:max-age=300]
 

Monarobase

Well-Known Member
#5
Thanks,

I was under the impression that those lines would first set the envrionement variable to private and then replace the private setting by max-age=300 thus being the equivalent of only max-age=300…

With Apache's mod_cache, Cache-Control should be set to :

"max-age=300, private"
 

Monarobase

Well-Known Member
#6
I've just tested :

RewriteRule \.php - [E=Cache-Control:private,E=Cache-Control:max-age=300]
Code:
X-LiteSpeed-Cache : hit

RewriteRule \.php - [E=Cache-Control:private]
Code:
X-LiteSpeed-Cache : hit,private
 

NiteWave

Administrator
#7
hmm ... I'd like to reproduce your result, to find out possible bugs.

what's the cache policy you set ? and any other rewrite rules ?

I did tests only for this simple php:
PHP:
/usr/local/lsws/DEFAULT/html>cat r.php
<?php
echo date("c");
echo "\n";
?>
 

Monarobase

Well-Known Member
#8
Hello,

My .htaccess file :

Code:
RewriteEngine On

RewriteRule \.php - [E=Cache-Control:private,E=Cache-Control:max-age=300]
#end of file
I used your r.php script

Cache-Crontrol is an environement variable, if you set it twice it's normal that the second value replaces the first.

You need to be able to set both values seperated by a comma. However I havn't found the correct syntax to do this :

I've tried without success things like this :
Code:
RewriteRule \.php - [E=Cache-Control:'private, max-age=180']
But it gives an error in ls logs:
Code:
ERROR	[[HTAccess]] rewrite: Unknown rewrite rule flag while parsing: RewriteRule \.php - [E=Cache-Control:'private, max-age=180']
My cache is set to :

Code:
Enable Cache : Not Set
Cache Expire Time (seconds) : Not Set
Cache Request with Query String : Yes
Cache Request with Cookie : No
Cache Response with Cookie : No
Ignore Request Cache-Control : No
Ignore Response Cache-Contro : No
Enable Private Cache : Not Set
Private Cache Expire Time (seconds) : 60
Thanks
 

NiteWave

Administrator
#9
my test result always:
Code:
X-LiteSpeed-Cache: hit,private
here's one of result:
Code:
~>curl -i 127.0.0.1/r.php
HTTP/1.1 200 OK
Date: Tue, 12 Feb 2013 10:55:17 GMT
Server: LiteSpeed/4.2.2 Enterprise
Connection: Keep-Alive
Keep-Alive: timeout=5, max=100
X-LiteSpeed-Cache: hit,private
Content-Length: 26
X-Powered-By: PHP/5.3.10
Content-Type: text/html

2013-02-12T18:55:14+08:00
I'm testing with lsws 4.2.2
 

Monarobase

Well-Known Member
#10
~ curl -i http://test.tld/r.php
HTTP/1.1 200 OK
Date: Tue, 12 Feb 2013 11:03:35 GMT
Server: LiteSpeed
X-LiteSpeed-Cache: hit
Content-Length: 26
Content-Type: text/html; charset=UTF-8
Connection: close

2013-02-12T12:03:34+01:00
I haven't upgraded to LiteSpeed/4.2.2 Enterprise yet (I'm running 4.2.1).

Is 4.2.2 in Release ?

In my WHM interface it says :

Latest Release: 4.2.1

I prefer to wait untill version 4.2.2 shows as an available update in the WHM interface unless the update feature doesn't work and will never show the next version ?
 

Monarobase

Well-Known Member
#12
Thanks I will wait for it to be marked stable enough to show in WHM.

Could this issue be resolved with version 4.2.2 ?

When you get a private cache hit, do you have the same settings for the cache ?

I don't want to activate the cache for the whole server but I want users to be able to activate and configure both private and public cache with .htaccess files.
 
#13
Could this issue be resolved with version 4.2.2 ?

When you get a private cache hit, do you have the same settings for the cache ?
I think so, 4.2.2 has new cache feature and we've done many internal tests, most likely it has fixed some cache bugs in older release.

yes, I've adjusted cache settings exactly with yours, and result is as expected:
X-LiteSpeed-Cache: hit,private
 
Top