How do i test if cache is working

Discussion in 'LiteSpeed Cache General' started by Ledgemonkey, Feb 14, 2013.

  1. Ledgemonkey

    Ledgemonkey Member

    what does this mean and how do you use it...?

    7. Verify if pages are served from LSWS cache

    Since 4.0.19 release, LiteSpeed outputs a response header “X-LiteSpeed-Cache: hit” if a request is served from cache.

    Since 4.1.1 release, LiteSpeed outputs a response header “X-LiteSpeed-Cache: hit,private” if a request is served from private cache.
  2. webizen

    webizen Well-Known Member

    A server response has headers. You can look at via firebug or run command line like 'curl -I'
    A response served from LS cache carries 'X-LiteSpeed-Cache' header as shown above
  3. Ledgemonkey

    Ledgemonkey Member

    testing cache

    Thanks for the reply:

    I have this in htttp.conf:

    LoadModule cache_module modules/
    <IfModule mod_cache.c>
    <IfModule mod_disk_cache.c>
    CacheRoot /tmp/diskcache/
    CacheEnable disk /

    I have files in tmp/diskcache/ 0/ 1/ 2/ 3/ a/ b/ c/ d/ e/ etc.

    my LS cache settings are :

    Storage Path:tmp/diskcache
    Max Object Size: 128K

    Cache Policy
    Enable Cache: No
    Cache Expire Time (seconds): Not Set
    Cache Request with Query String: No
    Cache Request with Cookie: No
    Cache Response with Cookie: No
    Ignore Request Cache-Control: No
    Ignore Response Cache-Control: No
    Enable Private Cache: Yes
    Private Cache Expire Time (seconds): 120

    I have this in my Magento .htaccess (which is not in root directory)

    RewriteEngine on
    RewriteRule cacheable/(.*\.php)?$ - [L,E=cache-control:max-age=120]

    Getting this from response header..?
    HTTP/1.1 200 OK
    Date: Fri, 15 Feb 2013 13:27:44 GMT
    Server: LiteSpeed
    Connection: Keep-Alive
    Keep-Alive: timeout=5, max=100
    X-Powered-By: PHP/5.3.21
    Set-Cookie: frontend=72ed1ce898e1dec005b44904ba6abc6a; expires=Fri, 15-Feb-2013 14:27:42 GMT; path=/;; HttpOnly
    Expires: Thu, 19 Nov 1981 08:52:00 GMT
    Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
    Pragma: no-cache

    Content-Type: text/html; charset=UTF-8
    Vary: User-Agent
    Vary: User-Agent

    Any ideas where I'm going wrong...?

    Many thanks...
  4. Ledgemonkey

    Ledgemonkey Member

    cache testing update

    I changed the Rewrite to:

    RewriteEngine on
    RewriteRule (.*\.php)?$ - [L,E=Cache-Control:max-age=120]

    And tested using curl -I - X-Litespeed-Cache:hit was in the response , but testing again and has stopped showing up.

    Can't be far away...!

    Have tried different rules but not working...?

    Any ideas...?

  5. webizen

    webizen Well-Known Member

    in cache policy, set ignore request/response cache-control header to yes.
  6. Ledgemonkey

    Ledgemonkey Member

    now getting X-LiteSpeed-Cache: hit response


    Now getting the X-LiteSpeed-Cache: hit response....

    Just need to get the rewrite rules correct so I don't cache the admin magento backend..
  7. webizen

    webizen Well-Known Member

    you can put the admin page url in the 'Do-Not-Cache URL' box. mouse over the 'i' pop-up window for more information.
  8. Ledgemonkey

    Ledgemonkey Member

    Can't seem to exclude the Magento admin area from cache , I've tried various settings in the 'Do-Not-Cache URL' box and in the .htaccess file but cant seem to be able to make it work.

    Any idea what the correct code could be in the .htaccess file to exclude all urls which contain "admin"..?

  9. webizen

    webizen Well-Known Member

  10. Ledgemonkey

    Ledgemonkey Member

    doesn't work tried all sorts...?

    What re-write rules should i use in htaccess ?

    If I use this RewriteRule (.*\.php)?$ - [L,E=Cache-Control:max-age=120] my pages break with Use Web Server Rewrites set to "yes" in amgento backend.

  11. webizen

    webizen Well-Known Member

    The wiki post is assuming you do not have any rewrite rules for LS cache.

    If you use rewrite rules for caching, you need to disable cache in Cache Policy. For non cache directory, you need add rules like

    I would not recommend to set 'Use Web Server Rewrites' to Yes as these are LSWS specifics.
  12. Ledgemonkey

    Ledgemonkey Member

    LS cache settings for Magento

    Hi, thanks for the response, I seem to have it working using these settings

    Enable Cache No
    Cache Expire Time (seconds) Not Set
    Cache Request with Query String Yes
    Cache Request with Cookie Yes
    Cache Response with Cookie Yes
    Ignore Request Cache-Control Yes
    Ignore Response Cache-Control Yes
    Enable Private Cache Yes
    Private Cache Expire Time (seconds)120

    .htacess :

    RewriteEngine on
    RewriteCond %{ORG_REQ_URI} !^/checkout/
    RewriteCond %{ORG_REQ_URI} !^/downloader
    RewriteCond %{ORG_REQ_URI} !^/index.php/admin
    RewriteCond %{ORG_REQ_URI} !^/customer
    # cache for 2 mins for php pages only
    RewriteRule (.*\.php)?$ - [E=Cache-Control:max-age=120]

    I have set the Use Web Server Rewrites to "Yes" then put "index.php" in front of /admin above and taken out the "L" in [L,E=Cache-Control:max-age=120]

    I will test further and update this thread...

    Thanks for your help

Share This Page