hit-for-pass clarification

Carlos Abalde carlos.abalde at gmail.com
Wed May 20 17:21:28 CEST 2015


> On 20 May 2015, at 17:08, kioto mitsubisi <reader_1000 at hotmail.com> wrote:
> 
> Hi,
> 
> Using a simple cgi script (as varnish book examples), I tested the scenario and it seems that I also need to remove set-cookie header from backend response, otherwise it create a hit-for-pass object.
> 
> #! /bin/sh
> sleep 5
> echo "Content-type: text/plain"
> #echo "Cache-control: max-age=0"
> echo "Set-Cookie: dummy=var; Path=/; HttpOnly"
> echo
> echo "Hello world"
> date

Hi,

'vcl_backend_response' in built-in VCL (https://github.com/varnish/Varnish-Cache/blob/master/bin/varnishd/builtin.vcl) creates a hit-for-pass object when the backend response contains a Set-Cookie header:

sub vcl_backend_response {
    if (beresp.ttl <= 0s ||
        beresp.http.Set-Cookie ||
        beresp.http.Surrogate-control ~ "no-store" ||
        (!beresp.http.Surrogate-Control &&
         beresp.http.Cache-Control ~ "no-cache|no-store|private") ||
        beresp.http.Vary == "*") {
        /*
         * Mark as "Hit-For-Pass" for the next 2 minutes
         */
        set beresp.ttl = 120s;
        set beresp.uncacheable = true;
    }
    return (deliver);
}

Please, check out https://github.com/varnish/Varnish-Book/blob/Varnish-Book-v4/varnish_book.rst#hit-for-pass for details.

Cheers,

--
Carlos Abalde




More information about the varnish-misc mailing list