diff --git a/templates/varnish.vcl.j2 b/templates/varnish.vcl.j2 index 1a49c00..85bb5f3 100644 --- a/templates/varnish.vcl.j2 +++ b/templates/varnish.vcl.j2 @@ -38,41 +38,24 @@ sub vcl_hash { } sub vcl_backend_response { set beresp.do_stream = false; + set beresp.do_gzip = true; + if (beresp.status == 500 || beresp.status == 502 || beresp.status == 503 || beresp.status == 504) { + if (bereq.is_bgfetch){ + return (abandon); + } + set beresp.uncacheable = true; + return (deliver); + } if (beresp.http.Set-Cookie || beresp.http.Cache-Control ~ "no-cache|no-store|private") { set beresp.uncacheable = true; - return(deliver); - } - if (beresp.http.Cache-Control ~ "no-cache") { - set beresp.ttl = 10m; - set beresp.grace = 5m; return (deliver); } - if (bereq.http.Host ~ "sd.redxen.eu") { - set beresp.ttl = 120s; - set beresp.keep = 7d; - set beresp.do_gzip = true; - set beresp.grace = 2h; - return (deliver); - } - set beresp.grace = 5m; if (beresp.http.ETag || beresp.http.Last-Modified || bereq.http.If-Modified-Since) { - set beresp.keep = 4h; + set beresp.keep = 12h; } if (beresp.status == 301) { set beresp.ttl = 24h; } - 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.do_gzip = true; - return (deliver); - } - set beresp.uncacheable = true; return (deliver); } sub vcl_deliver {