Add more advanced cache handling
This commit is contained in:
parent
da7b5f3afe
commit
cc1f1e1ad7
|
@ -9,11 +9,48 @@ backend default {
|
||||||
.between_bytes_timeout = 2s;
|
.between_bytes_timeout = 2s;
|
||||||
.proxy_header = 2;
|
.proxy_header = 2;
|
||||||
}
|
}
|
||||||
|
sub vcl_recv {
|
||||||
|
if ( req.method != "GET" &&
|
||||||
|
req.method != "HEAD" &&
|
||||||
|
req.method != "PUT" &&
|
||||||
|
req.method != "POST" &&
|
||||||
|
req.method != "TRACE" &&
|
||||||
|
req.method != "OPTIONS" &&
|
||||||
|
req.method != "PATCH" &&
|
||||||
|
req.method != "DELETE") {
|
||||||
|
return (pipe);
|
||||||
|
}
|
||||||
|
if (req.http.Upgrade ~ "(?i)websocket") {
|
||||||
|
return (pipe);
|
||||||
|
}
|
||||||
|
if (req.method != "GET" && req.method != "HEAD") {
|
||||||
|
return (pass);
|
||||||
|
}
|
||||||
|
return (hash);
|
||||||
|
}
|
||||||
|
sub vcl_hit {
|
||||||
|
if (obj.ttl + obj.grace > 0s) {
|
||||||
|
return (deliver);
|
||||||
|
}
|
||||||
|
return (pass);
|
||||||
|
}
|
||||||
|
sub vcl_pipe {
|
||||||
|
if (req.http.upgrade) {
|
||||||
|
set bereq.http.upgrade = req.http.upgrade;
|
||||||
|
}
|
||||||
|
return (pipe);
|
||||||
|
}
|
||||||
|
sub vcl_hash {
|
||||||
|
hash_data(req.url);
|
||||||
|
if (req.http.Cookie) {
|
||||||
|
hash_data(req.http.Cookie);
|
||||||
|
}
|
||||||
|
}
|
||||||
sub vcl_backend_response {
|
sub vcl_backend_response {
|
||||||
set beresp.ttl = 5m;
|
set beresp.grace = 1m;
|
||||||
if (bereq.url ~ "^[^?]*\.(7z|avi|bz2|flac|flv|gz|mka|mkv|mov|mp3|mp4|mpeg|mpg|ogg|ogm|opus|rar|tar|tgz|tbz|txz|wav|webm|xz|zip)(\?.*)?$") {
|
set beresp.keep = 4m;
|
||||||
unset beresp.http.set-cookie;
|
if (beresp.http.ETag || beresp.http.Last-Modified) {
|
||||||
set beresp.do_stream = true;
|
set beresp.keep = 4h;
|
||||||
}
|
}
|
||||||
return (deliver);
|
return (deliver);
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue