From 1e18560a7e63b36d464ceb52f248820fb7764719 Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 2 Jun 2020 15:43:33 +0200 Subject: [PATCH] Do more generous caching, cache stuff with etags and that either have a public cache header or no cache header --- templates/varnish.vcl.j2 | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/templates/varnish.vcl.j2 b/templates/varnish.vcl.j2 index 5aa6eb7..179c520 100644 --- a/templates/varnish.vcl.j2 +++ b/templates/varnish.vcl.j2 @@ -8,6 +8,7 @@ backend default { .between_bytes_timeout = 2s; } sub vcl_recv { + unset req.http.user-agent; if ( req.method != "GET" && req.method != "HEAD" && req.method != "PUT" && @@ -21,7 +22,7 @@ sub vcl_recv { if (req.http.Upgrade ~ "(?i)websocket") { return (pipe); } - if (req.http.Range) { + if (req.http.range) { return (pass); } if (req.method == "GET" || req.method == "HEAD") { @@ -50,14 +51,14 @@ sub vcl_pipe { return (pipe); } sub vcl_backend_response { - if (beresp.status == 500 || beresp.status == 502 || beresp.status == 503 || beresp.status == 504) { - return (abandon); + if (beresp.http.Cache-Control ~ "private") { + return (pass); } - if (beresp.http.Cache-Control ~ "public") { - return (deliver); + if (beresp.http.ETag || beresp.http.Last-Modified) { + set beresp.keep = 4h; } if (beresp.status == 301) { - return(deliver); + set beresp.ttl = 24h; } - return (pass); + return (deliver); }