[solved] Cache problem

Discussion in 'LiteSpeed Cache General' started by sahith, Jul 18, 2018.

  1. sahith

    sahith Well-Known Member

    Hi,
    I have added following code in my htaccess
    Code:
    RewriteRule ^(.*)$ - [E=Cache-Control:max-age=3600]
    RewriteRule scripts/api.php?limit=48&action=previews&page=1&type=ico_v&category=0 - [E=Cache-Control:no-cache]
    RewriteRule scripts/api.php?limit=18&action=previews&page=1&category=0&type=ico_v - [E=Cache-Control:no-cache]
    I want litespeed cache to exclude the urls in 2nd and 3rd lines. But its not excluding.

    And the first line is trying to cache whole website. But i only want to cache response pages start with scripts/api.php?, Is there a way?

    Need help.
     
    Last edited: Jul 18, 2018
  2. NiteWave

    NiteWave Administrator

    please change to
    Code:
    RewriteCond %{QUERY_STRING}  "limit=48&action=previews&page=1&type=ico_v&category=0"
    RewriteRule scripts/api.php - [E=Cache-Control:no-cache]
    
     
    sahith likes this.
  3. sahith

    sahith Well-Known Member

    So i added following code
    Code:
    RewriteRule ^(.*)$ - [E=Cache-Control:max-age=3600]
    RewriteCond %{QUERY_STRING}  "limit=48&action=previews&page=1&type=ico_v&category=0"
    RewriteCond %{QUERY_STRING}  "limit=18&action=previews&page=1&category=0&type=ico_v"
    RewriteRule scripts/api.php - [E=Cache-Control:no-cache]
    
    This is not working. And i need a rule to cache every response from scripts/api.php except those two rules.
     
    Last edited: Jul 18, 2018
  4. Pong

    Pong Well-Known Member Staff Member

    You need [OR] between two RewriteCond:

    Code:
    RewriteRule ^(.*)$ - [E=Cache-Control:max-age=3600]
    RewriteCond %{QUERY_STRING}  "limit=48&action=previews&page=1&type=ico_v&category=0" [OR]
    RewriteCond %{QUERY_STRING}  "limit=18&action=previews&page=1&category=0&type=ico_v"
    RewriteRule scripts/api.php - [E=Cache-Control:no-cache]
     
    sahith likes this.
  5. sahith

    sahith Well-Known Member

    Thats correct, Thanks

    Now my code is as follows
    Code:
    RewriteCond %{QUERY_STRING}  "limit"
    RewriteRule scripts/api.php -  [E=Cache-Control:max-age=3600]
    
    RewriteCond %{QUERY_STRING}  "limit=48&action=previews&page=1&type=ico_v&category=0" [OR]
    RewriteCond %{QUERY_STRING}  "limit=18&action=previews&page=1&category=0&type=ico_v" [OR]
    RewriteCond %{QUERY_STRING}  "category=0&type=ico_v&page=1&action=previews&limit=48"
    RewriteRule scripts/api.php - [E=Cache-Control:no-cache]
    So any string that contains "limit" after api.php should be cached ignoring those 3 conditions . Is this is the correct method?
     
  6. Pong

    Pong Well-Known Member Staff Member

    yes, you can do that.
     
    sahith likes this.
  7. sahith

    sahith Well-Known Member

    Dear NiteWave and Pong, Thank you very much for helping me out with your quick responses.
     
  8. Pong

    Pong Well-Known Member Staff Member

    You are welcome.
     

Share This Page