74 lines
1.7 KiB
Plaintext
74 lines
1.7 KiB
Plaintext
vcl 4.1;
|
|
import std;
|
|
|
|
backend default {
|
|
.host = "127.0.0.1";
|
|
.port = "7500";
|
|
.max_connections = 300;
|
|
.first_byte_timeout = 240s;
|
|
.connect_timeout = 10s;
|
|
.between_bytes_timeout = 2s;
|
|
}
|
|
sub vcl_recv {
|
|
unset req.http.user-agent;
|
|
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.method == "GET" || req.method == "HEAD") {
|
|
return (hash);
|
|
}
|
|
return (pass);
|
|
}
|
|
sub vcl_hash {
|
|
hash_data(req.url);
|
|
hash_data(req.http.host);
|
|
if (req.http.cookie ~ "pleroma_key|gitea_incredible|grafana_session") {
|
|
hash_data(req.http.cookie);
|
|
}
|
|
if (req.http.authorization) {
|
|
hash_data(req.http.authorization);
|
|
}
|
|
return (lookup);
|
|
}
|
|
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.ETag || beresp.http.Last-Modified || bereq.http.If-Modified-Since) {
|
|
set beresp.grace = 1h;
|
|
set beresp.keep = 12h;
|
|
}
|
|
if (beresp.status == 301) {
|
|
set beresp.ttl = 24h;
|
|
}
|
|
return (deliver);
|
|
}
|
|
sub vcl_deliver {
|
|
if (req.proto ~ "HTTP/2.0" && resp.http.keep-alive) {
|
|
unset resp.http.keep-alive;
|
|
}
|
|
if (obj.hits > 0) {
|
|
set resp.http.X-Cache = "HIT";
|
|
} else {
|
|
set resp.http.X-Cache = "MISS";
|
|
}
|
|
return (deliver);
|
|
}
|