next.js
2036a5b1 - [Cache Components] Avoid cache misses when resuming a cached page (#82578)

Commit
137 days ago
[Cache Components] Avoid cache misses when resuming a cached page (#82578) When a page component (or a parallel route slot) is cached, but other parts of the component tree are dynamic, we generate a partially static shell at buildtime that's resumed at runtime. During the resume, we need to ensure that the cache key is the same as during prerendering. This is currently not the case because we automatically include the (unused) `searchParams` prop in the cache key. Its value is a hanging promise during prerendering, and a resolving promise at runtime, leading to a cache miss when looking up the cached page data in the Resume Data Cache (RDC). Subsequently, hydration errors might occur when the recomputed result is different than the prerendered result. Since search params are not allowed to be read in public cache scopes anyways, we can pass erroring search params into the cached page, instead of using a hanging promise, and omit them from the generated cache key. We already used this technique when `cacheComponents` is not enabled. closes NAR-87
Author
Parents
Loading