Private cache max-age ?

Discussion in 'LiteSpeed Cache' started by Monarobase, Feb 10, 2013.

  1. Monarobase

    Monarobase Member

    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
  2. NiteWave

    NiteWave Administrator

    yes. just tested and confirm it works.
  3. Monarobase

    Monarobase Member

    Thanks,

    How would I do this ? All my tries failed…
  4. NiteWave

    NiteWave Administrator

    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]
  5. Monarobase

    Monarobase Member

    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"
  6. Monarobase

    Monarobase Member

    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
  7. NiteWave

    NiteWave Administrator

    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";
    ?>
  8. Monarobase

    Monarobase Member

    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
  9. NiteWave

    NiteWave Administrator

    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
  10. Monarobase

    Monarobase Member

    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 ?
  11. NiteWave

    NiteWave Administrator

    yes, 4.2.2 has been out for a while
    http://www.litespeedtech.com/litespeed-web-server-release-log.html
    and has run on some production server and I think it's stable enough now.

    you can switch between 4.2.1 and 4.2.2 anytime later without change the configuration file.

    to manually upgrade,
    #cd /usr/local/lsws/admin/misc
    #./lsup.sh -v 4.2.2

    4.2.2 will appear in WHM interface when we're sure it's stable enough.
  12. Monarobase

    Monarobase Member

    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. NiteWave

    NiteWave Administrator

    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

Share This Page