Last active
August 31, 2017 22:38
-
-
Save rezan/df7f30e994bbe5314220f42b38d6b651 to your computer and use it in GitHub Desktop.
Conditional grace turns into HFP while still fresh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
varnishtest "Conditional grace turns into HFP while obj.ttl > 0s" | |
server s1 -repeat 4 { | |
rxreq | |
txresp | |
} -start | |
varnish v1 -vcl+backend { | |
sub vcl_hit { | |
set req.http.X-status = "HIT"; | |
# Force a miss for the last 1s of fresh and while stale | |
if (obj.ttl < 1s) { | |
return (miss); | |
} | |
} | |
sub vcl_miss { | |
set req.http.X-status = "MISS"; | |
} | |
sub vcl_pass { | |
set req.http.X-status = "PASS"; | |
} | |
sub vcl_backend_response { | |
set beresp.ttl = 2s; | |
set beresp.grace = 1d; | |
} | |
sub vcl_deliver { | |
set resp.http.X-status = req.http.X-status; | |
} | |
} -start | |
client c1 { | |
# Cache miss | |
txreq -hdr "test: 1" | |
rxresp | |
expect resp.status == 200 | |
expect resp.http.X-status == "MISS" | |
# Normal cache hit | |
txreq -hdr "test: 2" | |
rxresp | |
expect resp.status == 200 | |
expect resp.http.X-status == "HIT" | |
delay 1.2 | |
# Force a miss on a fresh obj, this is a pass (no busyobj) | |
txreq -hdr "test: 3" | |
rxresp | |
expect resp.status == 200 | |
expect resp.http.X-status == "PASS" | |
txreq -hdr "test: 4" | |
rxresp | |
expect resp.status == 200 | |
expect resp.http.X-status == "PASS" | |
delay 1 | |
# Force a miss on a stale obj, this is a miss (we have a busyobj) | |
txreq -hdr "test: 5" | |
rxresp | |
expect resp.status == 200 | |
expect resp.http.X-status == "MISS" | |
# Back to a normal fresh obj | |
txreq -hdr "test: 6" | |
rxresp | |
expect resp.status == 200 | |
expect resp.http.X-status == "HIT" | |
} -run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment