Monitoring cache status

#1
I'm trying to write a script which will simply check for the x-litespeed-cache header as a hit once in a while. That is more or less done, however I'm never getting a cache hit..

My response headers look like:
Code:
'cache-control': 'private, proxy-revalidate, s-maxage=0',
'x-litespeed-tag': 'b5b_page,b5b_URL.e45fff28ff1f47129f3c634f10ffff02,b5b_Po.168471,b5b_PGS,f5f_',
'x-litespeed-cache': 'miss',
I've gone as far as saving cookies from the first request, passing them on a second request, and using a User-Agent string. No dice.
The pages I am checking are working (cache: hit) both in and out of incognito on different browsers. I just using a simple http request via nodejs.
I have noticed that via this client x-litespeed-tag doesn't appear to change across requests. Reading up on it but not yet sure if that matters.

Do I need to send a specific header? How do I configure my server so this is not abused by bots?
 
#4
I've made some progress on this that is interesting.
If I have a state or city cookie set upon request I will see a cache hit. If I have neither I will get a miss.
Could using this be the problem?
Code:
RewriteRule .* - [E="Cache-Vary:state, city"]
So my cache will correctly vary depending on the state/city but fail if that data is missing?
Any ideas? Most of my visitors are first-time hits so I could see this being an issue.

I can of course set a cookie in my script so my monitor works but I do want to solve this issue I've found.
 
#5
I've made some progress on this that is interesting.
If I have a state or city cookie set upon request I will see a cache hit. If I have neither I will get a miss.
Could using this be the problem?
Code:
RewriteRule .* - [E="Cache-Vary:state, city"]
So my cache will correctly vary depending on the state/city but fail if that data is missing?
Any ideas? Most of my visitors are first-time hits so I could see this being an issue.

I can of course set a cookie in my script so my monitor works but I do want to solve this issue I've found.
Hi @uselinux ,

I noticed this in your Response headers -
'cache-control': 'private, proxy-revalidate, s-maxage=0'

which would mean that you're using Private Cache, and then it would make sense makes sense if you're cache miss every time when you send the first request without a Cache-Vary.

Are you using Private Cache intentionally?
 
#6
No. Checking .htaccess I found this directive:
Code:
<filesMatch "\.(x?html?|php)$">
  Header set Cache-Control "private, must-revalidate"
</filesMatch>
Removing + clearing the cache doesn't appear to have changed anything.
 
#7
No. Checking .htaccess I found this directive:
Code:
<filesMatch "\.(x?html?|php)$">
  Header set Cache-Control "private, must-revalidate"
</filesMatch>
Removing + clearing the cache doesn't appear to have changed anything.
Do you use WordPress? If yes, It is controlled by the Plugin, Check the Cache section for URL's forced to be privately cached.
 
Top