Skip to content

Conversation

@nigoroll
Copy link
Member

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.

@gquintard
Copy link
Member

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.

@nigoroll
Copy link
Member Author

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.

Copy link
Member

@walid-git walid-git left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@nigoroll
Copy link
Member Author

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.

@bsdphk
Copy link
Contributor

bsdphk commented Dec 15, 2025

OK with me.

Copy link
Contributor

@SashankBhamidi SashankBhamidi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, I've had a look at your pull request and I have a few suggestions. I'm new to this codebase, so please feel free to correct me if I'm wrong.

Overall, I think this is a great addition to the std VMOD.

From the added documentation:

Re-calculate the object timers (``beresp.ttl``, ``beresp.grace`` and
``beresp.keep``) based on the current state of ``beresp`` as if it had been
processed by core code before ``vcl_backend_response`` was called. This does not
change ``beresp.uncacheable``.

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``.

Documentation details polished by SashankBhamidi, thank you.
@nigoroll nigoroll merged commit 39a9dae into varnishcache:master Dec 19, 2025
1 of 10 checks passed
@nigoroll nigoroll deleted the std.rfc_ttl branch December 19, 2025 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants