Have more generic caching settings, serve cached content from backends that are down as long as grace is on

This commit is contained in:
Alex 2020-07-03 12:51:32 +02:00
parent fee4131da3
commit 29c25ff024
Signed by: caskd
GPG Key ID: F92BA85F61F4C173
1 changed files with 9 additions and 26 deletions

View File

@ -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 {