Use defaults for hit, miss and pipe and don't pipe websockets, ignore client headers and use variable TTLs for objects

This commit is contained in:
Alex 2020-06-27 22:46:35 +02:00
parent e92e27ddfb
commit d7170d407e
Signed by: caskd
GPG Key ID: F92BA85F61F4C173
1 changed files with 5 additions and 21 deletions

View File

@ -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);
}