Skip to content

[Prefetch Inlining] Generate size-based hints on server#90891

Open
acdlite wants to merge 1 commit intovercel:canaryfrom
acdlite:segment-size-inlining
Open

[Prefetch Inlining] Generate size-based hints on server#90891
acdlite wants to merge 1 commit intovercel:canaryfrom
acdlite:segment-size-inlining

Conversation

@acdlite
Copy link
Contributor

@acdlite acdlite commented Mar 4, 2026

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.

@acdlite acdlite force-pushed the segment-size-inlining branch from f4a084e to 9d98b6a Compare March 4, 2026 21:28
@acdlite acdlite requested a review from ztanner March 4, 2026 21:29
@acdlite acdlite marked this pull request as ready for review March 4, 2026 21:29
@acdlite acdlite force-pushed the segment-size-inlining branch 3 times, most recently from 099b6a1 to a59a063 Compare March 6, 2026 07:26
@acdlite acdlite changed the title Segment Cache: size-based inlining hints Segment Cache: size-based inlining hints and server response generation Mar 6, 2026
@acdlite acdlite force-pushed the segment-size-inlining branch from a59a063 to 8c8f0c7 Compare March 6, 2026 07:31
@nextjs-bot
Copy link
Collaborator

nextjs-bot commented Mar 6, 2026

Tests Passed

@acdlite acdlite force-pushed the segment-size-inlining branch 5 times, most recently from 2b5dac7 to 01622a8 Compare March 6, 2026 08:42
@acdlite acdlite changed the title Segment Cache: size-based inlining hints and server response generation [Prefetch Inlining] Generate size-based hints on server Mar 6, 2026
@acdlite acdlite force-pushed the segment-size-inlining branch 10 times, most recently from 108db58 to 730ea6e Compare March 8, 2026 20:15
@acdlite acdlite force-pushed the segment-size-inlining branch from 730ea6e to f7e2844 Compare March 11, 2026 03:36
@acdlite acdlite force-pushed the segment-size-inlining branch from f7e2844 to 7d94d19 Compare March 11, 2026 05:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants