Files
RustProxy/examples/vcl/public-json-api.vcl
T
2026-11-20 17:18:02 +01:00

22 lines
676 B
Plaintext

// GET-only shared caching for /api/public. Other API routes bypass.
// The origin must mark genuinely public JSON responses as such.
sub vcl_recv {
if (req.method != "GET" && req.method != "HEAD") {
return(pass);
}
if (req.http.Authorization || req.http.Cookie) {
return(pass);
}
if (req.url ~ "^/api/public(/|[?]|$)") {
return(hash);
}
return(pass);
}
sub vcl_backend_response {
if (bereq.url ~ "^/api/public(/|[?]|$)" && beresp.status == 200 && beresp.http.Content-Type ~ "^application/json" && beresp.http.Cache-Control ~ "(^|,) *public(,|$)") {
set beresp.ttl = 15s;
set beresp.grace = 5s;
}
}