Page MenuHomePhabricator
Paste P6970

vcl_hit-deliver-keep.vtc
ActivePublic

Authored by ema on Apr 9 2018, 2:43 PM.
Tags
None
Referenced Files
F16866138:
Apr 9 2018, 3:01 PM
F16866085:
Apr 9 2018, 2:55 PM
F16866032:
Apr 9 2018, 2:43 PM
Subscribers
None
varnishtest "return deliver in vcl_hit (using keep)"
server s1 {
rxreq
txresp -hdr "Cache-Control: s-maxage=2" -hdr "Last-Modified: Tue, 03 Apr 2018 21:35:51 +0200" -hdr "X-Resp-ID: 1"
rxreq
txresp -hdr "Cache-Control: s-maxage=2" -hdr "Last-Modified: Tue, 03 Apr 2018 21:35:51 +0200" -hdr "X-Resp-ID: 2"
} -start
varnish v1 -vcl+backend {
sub vcl_backend_response {
set beresp.grace = 0s;
set beresp.keep = 5s;
}
sub vcl_hit {
return(deliver);
}
} -start
# First request, cache miss
client c1 {
txreq
rxresp
expect resp.http.X-Resp-ID == 1
} -run
varnish v1 -expect cache_hit == 0
varnish v1 -expect cache_miss == 1
# Second request, cache hit
client c2 {
txreq
rxresp
expect resp.http.X-Resp-ID == 1
} -run
varnish v1 -expect cache_hit == 1
varnish v1 -expect cache_miss == 1
# Third request waiting 3s to make the 2s ttl expire. This will result in a
# bgfetch and the stale object being returned. Still considered a cache hit.
client c3 {
delay 3
txreq
rxresp
expect resp.http.X-Resp-ID == 1
} -run
varnish v1 -expect cache_hit == 2
varnish v1 -expect cache_miss == 1
# Fourth request. This one returns the second object and is considered
# a cache hit as well.
client c4 {
txreq
rxresp
expect resp.http.X-Resp-ID == 2
} -run
varnish v1 -expect cache_hit == 3
varnish v1 -expect cache_miss == 1
varnish v1 -expect n_expired == 0

Event Timeline

ema changed the title of this paste from untitled to vcl_hit-deliver-keep.vtc.Apr 17 2018, 2:25 PM