perf(server): skip duplicate App RSC vary merge#2177
Merged
james-elicx merged 1 commit intoJun 20, 2026
Merged
Conversation
App Router page responses commonly already carry the internal RSC Vary header before response finalization runs. Re-running the generic Vary merge in that case splits and deduplicates the known header value on every SSR response without changing the result. Read the current Vary value first, set the internal header directly when missing, and only fall back to the generic merge path for custom Vary values that still need preservation and deduplication.
commit: |
Contributor
Performance benchmarksCompared 1 improved · 0 regressed · 4 within ±1.5%
View detailed results and traces 🟢 improvement · 🔴 regression · ⚫ change below 1.5% · paired base/head |
james-elicx
approved these changes
Jun 20, 2026
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.
Overview
This PR avoids running the generic
Varymerge path when App Router response finalization sees the internal RSCVaryheader is already present, or when the header is missing and can be set directly.VaryfinalizationVaryresponsesmergeVaryHeaderWhy
App page helpers already stamp
VINEXT_RSC_VARY_HEADERbeforefinalizeAppRscResponse()runs. The finalizer was still calling the generic merge helper, which reparsed and deduped the same known header value on every non-static App Router response.Validation
vp check tests/app-rsc-response-finalizer.test.ts packages/vinext/src/server/app-rsc-response-finalizer.tsvp test run tests/app-rsc-response-finalizer.test.tsvp run vinext#buildPerf note
Local 20k warmed SSR profile against the benchmark app showed
mergeVaryHeaderself-time on this path drop from70.33msto0ms, withfinalizeAppRscResponseself-time dropping from12.29msto5.37ms.Non-goals
This does not change the broader
mergeVaryHeaderhelper or optimize route tree construction. Those are separate hot paths.