Verifying origin cache related headers
Is there a way to view the cache related headers (cache-control, max-age etc.) served by the origin to Fastly? For example I came across “Fast-Debug:1” but from what I understand this only provides some Fastly related debug headers?
I want to inspect the headers provided by the origin to ensure that they’re correct / as expected as we optimise the cache behaviours: is there another way to do it besides connecting to the origin directly (a bit awkward to do)?
-
In custom VCL, you can add:
In
sub vcl_fetch
, close to the top:set beresp.http.X-Origin-Cache-Control = beresp.http.Cache-Control;
And in
sub vcl_deliver
:if (!req.http.Fastly-Debug) { unset resp.http.X-Origin-Cache-Control; }
This will make sure to always attach the
X-Origin-Cache-Control
value to the cached object, but will only expose it to the client ifFastly-Debug
is on.
Please sign in to leave a comment.
Comments
2 comments