Migrating v3 to v4: How to efectively detect a cache miss in VCL?

Carlos Peñas theistian at gmx.com
Wed May 14 11:15:47 CEST 2014


Hi. I'm starting the tests to migrate to v4 and I have an issue setting
headers to detect the HIT/MISS.

In v3 I was using the method described in https://www.varnish-cache.org/trac/wiki/VCLExampleHitMissHeader

sub vcl_deliver {
        if (obj.hits > 0) {
                set resp.http.X-Cache = "HIT";
        } else {
                set resp.http.X-Cache = "MISS";
        }
}

But now in varnish 4 when an url is banned the Age is reseted but obj.hits seems to remain the same

I've found this excerpt indicating the change of behaviour in obj.hits

https://www.varnish-cache.org/docs/trunk/whats-new/upgrading.html#obj-is-now-read-only


The bug indicated was closed indicating that obj.hits = 0 no longer indicates a cache MISS

So. How and where I can detect the handling and set a response header to indicate a real HIT/MISS?

Thanks




-- 
Carlos Peñas San José
carlos at adoptales.es




More information about the varnish-misc mailing list