Do more generous caching, cache stuff with etags and that either have a public cache header or no cache header

This commit is contained in:
Alex 2020-06-02 15:43:33 +02:00
parent 3e9080e219
commit 1e18560a7e
Signed by: caskd
GPG Key ID: F92BA85F61F4C173
1 changed files with 8 additions and 7 deletions

View File

@ -8,6 +8,7 @@ backend default {
.between_bytes_timeout = 2s;
}
sub vcl_recv {
unset req.http.user-agent;
if ( req.method != "GET" &&
req.method != "HEAD" &&
req.method != "PUT" &&
@ -21,7 +22,7 @@ sub vcl_recv {
if (req.http.Upgrade ~ "(?i)websocket") {
return (pipe);
}
if (req.http.Range) {
if (req.http.range) {
return (pass);
}
if (req.method == "GET" || req.method == "HEAD") {
@ -50,14 +51,14 @@ sub vcl_pipe {
return (pipe);
}
sub vcl_backend_response {
if (beresp.status == 500 || beresp.status == 502 || beresp.status == 503 || beresp.status == 504) {
return (abandon);
if (beresp.http.Cache-Control ~ "private") {
return (pass);
}
if (beresp.http.Cache-Control ~ "public") {
return (deliver);
if (beresp.http.ETag || beresp.http.Last-Modified) {
set beresp.keep = 4h;
}
if (beresp.status == 301) {
return(deliver);
set beresp.ttl = 24h;
}
return (pass);
return (deliver);
}