Don't allow session transfers, add debug headers and use gzip, set default ttl

This commit is contained in:
Alex 2020-06-13 22:20:34 +02:00
parent cdf0cbfcf2
commit 69a18ddf7f
Signed by: caskd
GPG Key ID: F92BA85F61F4C173
1 changed files with 22 additions and 3 deletions

View File

@ -22,7 +22,7 @@ sub vcl_recv {
if (req.http.Upgrade ~ "(?i)websocket") { if (req.http.Upgrade ~ "(?i)websocket") {
return (pipe); return (pipe);
} }
if (req.http.range || req.http.cache-control == "no-cache") { if (req.http.Range || req.http.cache-control == "no-cache") {
return (pass); return (pass);
} }
if (req.method == "GET" || req.method == "HEAD") { if (req.method == "GET" || req.method == "HEAD") {
@ -51,8 +51,9 @@ sub vcl_pipe {
return (pipe); return (pipe);
} }
sub vcl_backend_response { sub vcl_backend_response {
if (beresp.http.Cache-Control ~ "private" || beresp.http.Content-Type == "text/html") { set beresp.ttl = 30m;
return (pass); if (beresp.http.Set-Cookie) {
return(pass);
} }
if (beresp.http.ETag || beresp.http.Last-Modified) { if (beresp.http.ETag || beresp.http.Last-Modified) {
set beresp.keep = 4h; set beresp.keep = 4h;
@ -60,5 +61,23 @@ sub vcl_backend_response {
if (beresp.status == 301) { if (beresp.status == 301) {
set beresp.ttl = 24h; set beresp.ttl = 24h;
} }
if ( 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);
}
return (pass);
}
sub vcl_deliver {
if (obj.hits > 0) {
set resp.http.X-Cache = "HIT";
} else {
set resp.http.X-Cache = "MISS";
}
return (deliver); return (deliver);
} }