Skip to content

Instantly share code, notes, and snippets.

@rezan
Last active October 8, 2015 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rezan/4f074e5fa5e3bcecd9b3 to your computer and use it in GitHub Desktop.
Save rezan/4f074e5fa5e3bcecd9b3 to your computer and use it in GitHub Desktop.
add hit, miss, grace, keep, and ttl headers
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