Litespeed cache not obeying .htaccess rules

Discussion in 'LiteSpeed Cache General' started by jacob, May 16, 2013.

  1. jacob

    jacob Member


    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 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:

    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: May 16, 2013
  2. mistwang

    mistwang LiteSpeed Staff

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

    private cache was processed before .htaccess.
  3. jacob

    jacob Member

    So what you're saying is that if private cache is globally enabled there is no way to disable it via .htaccess?
  4. mistwang

    mistwang LiteSpeed Staff

    that's correct.
  5. jacob

    jacob Member

  6. webizen

    webizen Well-Known Member

    you need to purge the private cache copy if it still valid. document is updated accordingly.
  7. jacob

    jacob Member

    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: May 17, 2013
  8. Sindre

    Sindre Well-Known Member

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

    NiteWave Administrator

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

    Sindre Well-Known Member

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

    NiteWave Administrator

    yes. through
    CacheEnable private
    RewriteRule /a-b-c-d.php - [E=Cache-Control:private]
    RewriteRule /a-b-c-d.php - [E=Cache-Control:max-age=60]  #for public cache
    also disable particular URL's public cache by
    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.

Share This Page