On Fri, Aug 10, 2012 at 5:49 AM, Connor Walls
<[email protected]> wrote:
> 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:
[...]
> 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?

Try setting http headers on vcl_miss (when it needs to fetch from
backend) and vcl_hit (when it doesn't). Then o vcl_deliver you set de
resp.http.* based on these. Example:

sub vcl_hit {
  set req.http.X-Varnish-TTL = obj.ttl;
  set req.http.X-Varnish-Cache = "hit";
}

sub vcl_miss {
  set req.http.X-Varnish-TTL = 0;
  set req.http.X-Varnish-Cache = "miss";
}

sub vcl_deliver {
  set resp.http.X-Varnish-TTL = req.http.X-Varnish-TTL;
  set resp.http.X-Varnish-Cache = req.http.X-Varnish-Cache;
}

-- 
[]'s
Hugo
www.devin.com.br

_______________________________________________
varnish-misc mailing list
[email protected]
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc

Reply via email to