Page MenuHomePhabricator
Authored By
ema
Apr 9 2018, 2:43 PM
Size
1 KB
Referenced Files
None
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.
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 == 1

File Metadata

Mime Type
text/plain; charset=utf-8
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5720005
Default Alt Text
(1 KB)

Event Timeline