Vanish 4 effectively detect HIT / MISS in VCL
From V4 obj.hits no longer reports the number of hits for a cached object, so a cache MISS does't mean a obj.hits == 0
Some on the Varnish misc list states that varnish sets the X-Varnish header with two numbers when it is a hit and only one if not. So you ned somethig like this to get HIT/MISS in a header:
sub vcl_deliver {
if (resp.http.X-Varnish ~ "[0-9]+ +[0-9]+") {
set resp.http.X-Cache = "HIT";
} else {
set resp.http.X-Cache = "MISS";
}
}
Written by Carlos
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Varnish
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#