Created
May 7, 2025 21:04
-
-
Save eksiscloud/58cf8090ec76ab2e7fa83b27065cda7a to your computer and use it in GitHub Desktop.
Varnish hit/miss/pass counter
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
sub vcl_recv { | |
unset req.http.x-cache; | |
} | |
sub vcl_hit { | |
set req.http.x-cache = "hit"; | |
if (obj.ttl <= 0s && obj.grace > 0s) { | |
set req.http.x-cache = "hit graced"; | |
} | |
} | |
sub vcl_miss { | |
set req.http.x-cache = "miss"; | |
} | |
sub vcl_pass { | |
set req.http.x-cache = "pass"; | |
} | |
sub vcl_pipe { | |
set req.http.x-cache = "pipe uncacheable"; | |
} | |
sub vcl_synth { | |
set req.http.x-cache = "synth synth"; | |
# uncomment the following line to show the information in the response | |
# set resp.http.x-cache = req.http.x-cache; | |
} | |
sub vcl_deliver { | |
if (obj.uncacheable) { | |
set req.http.x-cache = req.http.x-cache + " uncacheable" ; | |
} else { | |
set req.http.x-cache = req.http.x-cache + " cached" ; | |
} | |
# uncomment the following line to show the information in the response | |
# set resp.http.x-cache = req.http.x-cache; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment