From d7170d407eae6fb9737654e7195f03578e61e87e Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 27 Jun 2020 22:46:35 +0200 Subject: [PATCH] Use defaults for hit, miss and pipe and don't pipe websockets, ignore client headers and use variable TTLs for objects --- templates/varnish.vcl.j2 | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/templates/varnish.vcl.j2 b/templates/varnish.vcl.j2 index c99a633..fb918b2 100644 --- a/templates/varnish.vcl.j2 +++ b/templates/varnish.vcl.j2 @@ -20,12 +20,6 @@ sub vcl_recv { req.method != "DELETE") { return (pipe); } - if (req.http.Upgrade ~ "(?i)websocket") { - return (pipe); - } - if (req.http.cache-control == "no-cache") { - return (pass); - } if (req.method == "GET" || req.method == "HEAD") { return (hash); } @@ -37,28 +31,19 @@ sub vcl_hash { if (req.http.cookie) { hash_data(req.http.cookie); } + if (req.http.authorization) { + hash_data(req.http.authorization); + } return (lookup); } -sub vcl_hit { - return (deliver); -} -sub vcl_miss { - return (fetch); -} -sub vcl_pipe { - return (pipe); -} sub vcl_backend_response { set beresp.do_stream = false; if ( beresp.http.Set-Cookie || - beresp.http.Cache-Control ~ "no-cache|no-store|private" || - std.integer(beresp.http.Content-Length, 0) > 20971520) { + beresp.http.Cache-Control ~ "no-cache|no-store|private") { set beresp.uncacheable = true; return(deliver); } - set beresp.ttl = 120s; - set beresp.keep = 10s; - set beresp.grace = 30s; + set beresp.grace = 5m; if (beresp.http.ETag || beresp.http.Last-Modified) { set beresp.keep = 4h; } @@ -73,7 +58,6 @@ sub vcl_backend_response { beresp.http.Content-Type ~ "video" || beresp.http.Content-Type ~ "audio" || beresp.http.Content-Type ~ "font") { - set beresp.ttl = 10m; set beresp.do_gzip = true; return (deliver); }