[Cache Components] Don't propagate tags/life for omitted caches (#82884)
Caches with staleness/expiration below certain thresholds are not
included in static prerenders and are treated as dynamic. However, the
logic for propagating life/tags did not factor this in, meaning that a
prerender could get `cacheLife("seconds")`, making it expire (both on
the server and in the client router cache) much earlier than necessary.
This PR fixes that.
Closes NAR-271
### Implementation notes
The solution relies on the fact that in a Cache Components prerender,
we'll first fill the caches in the prospective render, and then read
them again in the final prerender. Previously, we'd propagate cache
life/tags in the prospective render, when the cache was filled, but this
didn't factor in the fact that the final render might decide to omit the
cache, leading to the problem described earlier. After this change,
we'll be relying on the fact that the entry will be read in the final
prerender, at which point we decide if it should be included or not, and
then propagate cache life/tags if it is.
Additionally, we filter the omitted cache entries from the resume data
cache (RDC). Otherwise they would be available during the resume, which
they should not be.
To be honest, this feels a bit brittle, and perhaps we should take a
look at how we're handling this and make it cleaner, but it should work
for now.
---------
Co-authored-by:
Hendrik Liebau <mail@hendrik-liebau.de>
Showing
Please
register
or
sign in
to comment