[solved] Cache problem

sahith

Well-Known Member
#1
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:

NiteWave

Administrator
#2
RewriteRule scripts/api.php?limit=48&action=previews&page=1&type=ico_v&category=0 - [E=Cache-Control:no-cache]
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

Well-Known Member
#3
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:

Pong

Administrator
Staff member
#4
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

Well-Known Member
#5
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?
 
Top