mirror of
https://github.com/KevinMidboe/infra-map.git
synced 2025-10-29 17:40:28 +00:00
sets up varnish cache server with: - custom cache per content type - gzip - configure app & hass backends - varnish debug headers & X-Cache verbose cache header also updates docker-compose, varnish/Dockerfile & drone.
44 lines
1.3 KiB
Plaintext
44 lines
1.3 KiB
Plaintext
sub vcl_recv {
|
|
unset req.http.X-Cache;
|
|
}
|
|
|
|
sub vcl_hit {
|
|
set req.http.X-Cache = "HIT";
|
|
}
|
|
|
|
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 resp.http.X-Cache = "SYNTH";
|
|
}
|
|
|
|
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" + " (real age: " + resp.http.Age + ", hits: " + obj.hits + ", ttl: " + resp.http.x-ttl + ")";
|
|
}
|
|
|
|
# if we are gracing, make sure the browser doesn't cache things, and set our maxage to 1
|
|
# also log grace delivery
|
|
if (req.http.graceineffect) {
|
|
set resp.http.Cache-Control = regsub(resp.http.Cache-Control, "max-age=[0-9]*", "max-age=1");
|
|
set resp.http.Cache-Control = regsub(resp.http.Cache-Control, "channel-maxage=[0-9]*", "channel-maxage=1");
|
|
set req.http.X-Cache = req.http.X-Cache + " [grace: " + req.http.graceineffect + " " + req.http.grace + ", remaining: " + req.http.graceduration + "]";
|
|
}
|
|
|
|
# uncomment the following line to show the information in the response
|
|
set resp.http.X-Cache = req.http.X-Cache;
|
|
}
|
|
|