fix max-age parsing, remove some varnish ehaders

This commit is contained in:
Thomas Lynch
2024-11-13 16:15:40 +11:00
parent 0016aa5204
commit 83c2b397e8

View File

@ -57,7 +57,7 @@ sub vcl_backend_response {
return (pass);
} else if (beresp.http.Cache-Control ~ "max-age") {
# if max-age is provided, use it directly
set beresp.ttl = std.duration(regsub(beresp.http.Cache-Control, ".*max-age=([0-9]+).*", "\1"), 0s);
set beresp.ttl = std.duration(regsub(beresp.http.Cache-Control, ".*max-age=([0-9]+).*", "\1") + "s", 0s);
} else if (beresp.http.Expires) {
# if using expire, calculate remaining TTL
set beresp.ttl = std.duration(beresp.http.Expires, 0s);
@ -83,6 +83,8 @@ sub vcl_backend_response {
# caching behavior when sending response
sub vcl_deliver {
unset resp.http.X-Varnish;
unset resp.http.Via;
# custom header to tell whether req was served from cache
if (obj.hits > 0) {
set resp.http.X-Cache = "HIT";