Last active
October 8, 2015 14:00
-
-
Save rezan/4f074e5fa5e3bcecd9b3 to your computer and use it in GitHub Desktop.
add hit, miss, grace, keep, and ttl headers
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; | |
#put this near the top of the parent vcl: | |
#include "hit_miss.vcl"; | |
sub vcl_hit | |
{ | |
set req.http.X-status = "HIT"; | |
set req.http.X-ttl = obj.ttl; | |
set req.http.X-grace = obj.grace; | |
set req.http.X-keep = obj.keep; | |
} | |
sub vcl_miss | |
{ | |
set req.http.X-status = "MISS"; | |
} | |
sub vcl_pass | |
{ | |
set req.http.X-status = "PASS"; | |
} | |
sub vcl_backend_response | |
{ | |
set beresp.http.X-full-ttl = beresp.ttl; | |
} | |
sub vcl_deliver | |
{ | |
set resp.http.X-status = req.http.X-status; | |
set resp.http.X-hits = obj.hits; | |
if (resp.http.X-status == "HIT") | |
{ | |
set resp.http.X-ttl = req.http.X-ttl; | |
set resp.http.X-grace = req.http.X-grace; | |
set resp.http.X-keep = req.http.X-keep; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment