[Prefetch Inlining] Generate size-based hints on server#90891
Open
acdlite wants to merge 1 commit intovercel:canaryfrom
Open
[Prefetch Inlining] Generate size-based hints on server#90891acdlite wants to merge 1 commit intovercel:canaryfrom
acdlite wants to merge 1 commit intovercel:canaryfrom
Conversation
f4a084e to
9d98b6a
Compare
packages/next/src/server/app-render/walk-tree-with-flight-router-state.tsx
Outdated
Show resolved
Hide resolved
099b6a1 to
a59a063
Compare
a59a063 to
8c8f0c7
Compare
Collaborator
Tests Passed |
2b5dac7 to
01622a8
Compare
108db58 to
730ea6e
Compare
730ea6e to
f7e2844
Compare
f7e2844 to
7d94d19
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.
Part 1 of 2. This commit adds the server-side infrastructure for size-based segment bundling but does not change any observable behavior. The client-side changes that actually consume bundled responses are in the next commit.
At build time, a measurement pass renders each segment's prefetch response, measures its gzip size, and decides which segments should be bundled together vs fetched separately. The decisions are persisted to a manifest and embedded into the route tree prefetch response so the client can act on them.
The decisions are computed once at build and remain fixed for the lifetime of the deployment. They are not recomputed during ISR/revalidation — if they could change, the client would need to re-fetch the route tree after every revalidation, defeating the purpose of caching it independently.
Refer to the next commit for a full description of the design and motivation.
Config
experimental.prefetchInlining accepts either a boolean or an object with threshold overrides (maxSize, maxBundleSize). When true, the default thresholds are used (2KB per-segment, 10KB total budget). The auto behavior will eventually become the default. The config will remain available for overriding thresholds.