mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
50edb74488
## What? This PR introduces the Resume Data Cache (RDC) functionality to improve handling of dynamic React Server Component (RSC) requests when Partial Pre-rendering (PPR) is enabled. This enhancement enables dynamic RSC responses to utilize the Resume Data Cache, significantly reducing waterfalls and preventing content shearing. ## Why? Previously, dynamic RSC requests with PPR enabled experienced several issues: **Waterfall Reduction:** Dynamic RSC responses required multiple waterfalls to hydrate a given cache, leading to slower response times and unnecessary network round-trips. **Content Shearing Prevention:** There were mismatches between static cached parts of the page and the dynamic response, causing visual inconsistencies and potential hydration errors. By ensuring the RDC generated for static responses is also used for dynamic RSC responses, we maintain consistency even when the dynamic response interacts with caches directly and potentially receives newer, non-stale values. **Additional Issues Addressed:** - Stale content revalidation not triggering correctly - Background revalidation producing dynamic responses instead of static ones - Inconsistent cache tag staleness evaluation - Missing support for resumable rendering in dynamic contexts ## How? **Core Implementation:** - Added Resume Data Cache layer that stores resumable render data for dynamic RSC requests - Ensures the same RDC used by static responses is reused for dynamic RSC responses - Introduced `forceStaticRender` flag to ensure background revalidation generates static responses - Refactored response cache internals to separate cache entry creation from response handling - Enhanced error handling with try-catch blocks for server actions in app-render **Revalidation Improvements:** - Fixed cache tag staleness evaluation for consistent behavior - Improved triggering logic for background revalidation of stale dynamic content - Better handling of cache misses and "no-resume-data" scenarios with debug logging --------- Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com>