Skip to content

Instantly share code, notes, and snippets.

@rezan
Last active July 20, 2018 13:57
Show Gist options
  • Select an option

  • Save rezan/ec1fe99c27b761e16b1d0bf8e4822828 to your computer and use it in GitHub Desktop.

Select an option

Save rezan/ec1fe99c27b761e16b1d0bf8e4822828 to your computer and use it in GitHub Desktop.
hit_miss.vcl for Varnish 6.0
# hit_miss.vcl for Varnish 6.0
vcl 4.0;
# What are we, hit, miss, or pass?
sub vcl_recv {
set req.http.X-status = "NONE";
}
sub vcl_hit {
set req.http.X-status = "HIT";
}
sub vcl_miss {
set req.http.X-status = "MISS";
}
sub vcl_pass {
set req.http.X-status = "PASS";
}
sub vcl_deliver {
# Cache status
set resp.http.X-cache = obj.hits + " (" + req.http.X-status + ":" +
server.identity + ") " + resp.http.X-cache;
# Other stats
set resp.http.X-hits = std.integer(resp.http.X-hits, 0) + obj.hits;
set resp.http.X-ttl = obj.ttl;
set resp.http.X-grace = obj.grace;
set resp.http.X-keep = obj.keep;
set resp.http.X-uncacheable = obj.uncacheable;
}
sub vcl_synth {
# Cache status
set resp.http.X-cache = "(SYNTH:" + server.identity + ")";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment