Last active
July 21, 2017 13:55
-
-
Save rezan/91499d1588b4148612e99fda4f3f9ea8 to your computer and use it in GitHub Desktop.
Properly handle grace across multiple tiers
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
vcl 4.0; | |
# Include this VCL on all tiers | |
# Call this once on the Edge tier | |
sub dvcl_init_edge | |
{ | |
unset req.http.X-DVCL-skip-grace; | |
} | |
sub vcl_recv | |
{ | |
unset req.http.X-DVCL-graced; | |
} | |
sub vcl_hit | |
{ | |
if (obj.ttl < 0s) { | |
set req.http.X-DVCL-graced = "true"; | |
if (req.http.X-DVCL-skip-grace == "true") { | |
return (fetch); | |
} | |
} | |
# Fall thru to vcl_hit and possibly hit conditional grace/miss logic | |
} | |
sub vcl_backend_fetch | |
{ | |
# If we come here, we are either a bgfetch or a condition grace/miss | |
# In either case, we want something fresh, so disable grace on all following tiers | |
if (bereq.http.X-DVCL-graced == "true") { | |
set bereq.http.X-DVCL-skip-grace = "true"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment