Cached Navigations: Cache static stage of partially static initial HTML#90539
Draft
unstubbable wants to merge 1 commit intohl/cached-navs-2from
Draft
Cached Navigations: Cache static stage of partially static initial HTML#90539unstubbable wants to merge 1 commit intohl/cached-navs-2from
unstubbable wants to merge 1 commit intohl/cached-navs-2from
Conversation
Contributor
Author
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
This was referenced Feb 25, 2026
Collaborator
Failing test suitesCommit: d37c0ed | About building and testing Next.js
Expand output● Dev Rendering Indicator › Shows build indicator when page is built from modifying |
59984fa to
c0d147a
Compare
When a partially static page is loaded via initial HTML (PPR resume), the RSC payload now includes the `l` (static stage byte length) field, enabling the client to extract and cache the static stage during hydration. Subsequent navigations to the same page serve the cached static content instantly while streaming in dynamic content. On the server, the resume path in `renderToStream` now uses staged rendering (mirroring `generateStagedDynamicFlightRenderResult`) when Cache Components is enabled. A `StagedRenderingController` separates the static and dynamic stages, and `countStaticStageBytes` resolves the byte length promise that Flight serializes into the stream as `l`. `getRSCPayload` accepts `staleTimeIterable` and `staticStageByteLengthPromise` options to wire `s` and `l` into the `InitialRSCPayload`. On the client, `app-index.tsx` tees the inlined Flight stream when Cache Components is enabled. One copy goes to React for decoding, the other is passed to `createInitialRouterState`. When `l` is present (partially static), the clone is truncated at the byte boundary via the new `decodeStaticStage` helper and written into the segment cache via `processStaticStageResponse` and `writeStaticStageResponseIntoCache`. When `l` is absent but `s` is present (fully static), the existing `writeInitialSeedDataIntoCache` path is used unchanged. `createInitialRouterState` now accepts a single `initialRSCPayload: InitialRSCPayload` prop instead of individual destructured fields. `resolveStaticStageData`, `processStaticStageResponse`, `writeStaticStageResponseIntoCache`, and `writeDynamicRenderResponseIntoCache` are widened to accept `NavigationFlightResponse | InitialRSCPayload`.
37de8e8 to
d37c0ed
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

When a partially static page is loaded via initial HTML (PPR resume), the RSC payload now includes the
l(static stage byte length) field, enabling the client router to extract and cache the static stage during hydration. Subsequent navigations to the same page serve the cached static content instantly while streaming in dynamic content.On the server, the resume path in
renderToStreamnow uses staged rendering (mirroringgenerateStagedDynamicFlightRenderResult) when Cache Components is enabled. AStagedRenderingControllerseparates the static and dynamic stages, andcountStaticStageBytesresolves the byte length promise that Flight serializes into the stream asl.getRSCPayloadacceptsstaleTimeIterableandstaticStageByteLengthPromiseoptions to wiresandlinto theInitialRSCPayload.On the client,
app-index.tsxtees the inlined Flight stream when Cache Components is enabled. One copy goes to React for decoding, the other is passed tocreateInitialRouterState. Whenlis present (partially static), the clone is truncated at the byte boundary via the newdecodeStaticStagehelper and written into the segment cache viaprocessStaticStageResponseandwriteStaticStageResponseIntoCache. Whenlis absent butsis present (fully static), the existingwriteInitialSeedDataIntoCachepath is used unchanged.createInitialRouterStatenow accepts a singleinitialRSCPayload: InitialRSCPayloadprop instead of individual destructured fields.resolveStaticStageData,processStaticStageResponse,writeStaticStageResponseIntoCache, andwriteDynamicRenderResponseIntoCacheare widened to acceptNavigationFlightResponse | InitialRSCPayload.