Determine if ESI object is cached

Crowder, Travis Travis.Crowder at penton.com
Thu Mar 21 19:18:09 CET 2013


Is there a way to determine if an ESI call came from cache or a backend?

I am trying to set a HTTP header on an ESI cache hit or miss, but am not having as much success as when checking for a non-ESI request.

In the recv, I set do_esi to true and the x-esi-request value, in deliver I have the code below which doesn't seem to work at all.  I don't see any X-ESI-Cache headers in varnishlog

In vcl_deliver:

if(obj.hits > 0){
        if(resp.http.x-esi-request == "Yes"){ set resp.http.X-ESI-Cache = "Cached"; }
        set resp.http.X-Cache = "Cached";
        set resp.http.X-Hits = obj.hits;
    } else {
        if(resp.http.x-esi-request == "Yes"){ set resp.http.X-ESI-Cache = "Fresh"; }
        set resp.http.X-Cache = "Fresh";
    }

    return (deliver);

Any assistance is appreciated.

Thanks,
Travis
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20130321/6f76d759/attachment.html>


More information about the varnish-misc mailing list