diff --git a/templates/varnish.vcl.j2 b/templates/varnish.vcl.j2 index fd30899..b381c50 100644 --- a/templates/varnish.vcl.j2 +++ b/templates/varnish.vcl.j2 @@ -22,7 +22,7 @@ sub vcl_recv { if (req.http.Upgrade ~ "(?i)websocket") { return (pipe); } - if (req.http.Range || req.http.cache-control == "no-cache") { + if (req.http.cache-control == "no-cache") { return (pass); } if (req.method == "GET" || req.method == "HEAD") { @@ -51,27 +51,34 @@ sub vcl_pipe { return (pipe); } sub vcl_backend_response { - set beresp.ttl = 30m; - if (beresp.http.Set-Cookie) { - return(pass); + set beresp.do_stream = false; + if ( beresp.http.Set-Cookie || + beresp.http.Cache-Control ~ "no-cache|no-store|private" || + beresp.http.Vary == "*") { + set beresp.uncacheable = true; + return(deliver); } + set beresp.ttl = 120s; if (beresp.http.ETag || beresp.http.Last-Modified) { set beresp.keep = 4h; } if (beresp.status == 301) { set beresp.ttl = 24h; } - if ( beresp.http.Cache-Control ~ "public" || + if ( bereq.http.Host == "redxen.eu" || + beresp.http.Cache-Control ~ "public" || beresp.http.Content-Type ~ "text/css" || beresp.http.Content-Type ~ "text/javascript" || beresp.http.Content-Type ~ "image" || 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); } - return (pass); + set beresp.uncacheable = true; + return (deliver); } sub vcl_deliver { if (obj.hits > 0) {