Adding header depending on if request was fetched or passed

Connor Walls connor.walls at
Fri Aug 10 10:49:22 CEST 2012

Hi all,

So, as it stands we have the fairly common set up in our vcl_deliver to add a header to indicate whether or not the object was served from cache or not:

    if (obj.hits > 0)
        set resp.http.X-Cache = "HIT";
        set resp.http.X-Cache = "MISS";

Now, in addition to this, I was wondering if it would be possible to add a header to indicate whether or not we attempted to fetch the object from cache, i.e. if the request had gone through vcl_fetch or vcl_pass. My initial thought was to add some form of header in those subroutines but obviously I'm not able to access resp here. Is there anything that obj would be able to tell me in vcl_deliver about this?

Thanks for any help,

More information about the varnish-misc mailing list