Add std.rfc_ttl()
From the added documentation:
Re-calculate the object timers (beresp.ttl, beresp.grace and beresp.grace) and cacheability status based on the current state of beresp as if it had been processed by core code before vcl_backend_response was called.
This is useful to get the default ttl calculations after modifications of relevant properties like beresp.status, beresp.http.Date, beresp.http.Age or beresp.http.Cache-Control.
this is massively welcome. But maybe we should also offer the opposite? i.e. modify the headers to match the beresp.* properties? It's quite a bit more work and a can of worms on its own, but worth mentioning, even if it doesn't invalidate the need for this PR.
maybe we should also offer the opposite?
Yes, some standard function to create Cache-Control based on the state of an object could be useful. Bug please let's keep this separate.
I have updated the PR to also allow std.rfc_ttl() from vcl_backend_refresh, for which most of the work was to adjust the test case, because I got lured into a rabbit hole regarding ttl <= 0s being uncacheable and whether or not that still makes sense. But I got out before turning the hole into a burrow.
OK with me.