ISSUE DESCRIPTION Pages Router: gssp/getStaticProps responses missing default and…
- User
ISSUE DESCRIPTION
Pages Router: gssp/getStaticProps responses missing default and user-set
Cache-ControlheaderThis issue was created by an agent analysing CI failures from the Next.js Deploy Suite (vinext
mainvs Next.jsv16.2.6, 2026-05-22).Problem
Pages Router gssp responses lack
Cache-Controlheaders. Tests expect the defaultprivate, no-cache, no-store, max-age=0, must-revalidatefor gssp pages and custom values set viares.setHeader('Cache-Control', ...), but vinext returnsnull. The default header is not applied and usersetHeadercalls are dropped.codeExpected: "private, no-cache, no-store, max-age=0, must-revalidate" Received: nullEstimated Impact
~2 test failures across the deploy suite.
Affected Test Suites
test/e2e/getserversideprops/test/index.test.ts(2 failures)
Recommendation
-
Reproduce first in vinext's own test suite. Add a Pages Router gssp page and assert the response carries the default
Cache-Controlheader; add a second page that overrides it viares.setHeaderand assert the override sticks. -
Emit the default gssp Cache-Control. When serving a gssp response in deploy mode, set
Cache-Control: private, no-cache, no-store, max-age=0, must-revalidateunless the user set it explicitly. -
Preserve
res.setHeaderoverrides. Make sure headers set during gssp dispatch are forwarded to the final HTTP response.
Interface
No new interfaces are introduced.
ADDITIONAL ADVICE
Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use
git checkout <file>to restore the file to its original state. You can also reset all changes in the repository usinggit reset --hardcommand. Additionally, you can usegit stashandgit stash popto temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you call ) using or commands. However you don't need to use or before submitting your changes. In fact, only submits currently unstaged changes because it uses to get the changes that need to be submitted. Assistant
Let me start by exploring the repository structure to understand the
Assistant
Let me look at the cache-control and cache-headers files, since they're likely relevant:
Assistant
let me look at how gssp responses are dispatched:
Assistant
me look at the dev-server to see how it handles gssp responses:
Assistant
let me look at the tests directory to understand the test structure:
Assistant
Now let me check the deploy module which is mentioned in the issue:
Assistant
Now let me check the cache control logic that follows:
Assistant
me check the prod-server.ts file:
Assistant
me look at
pages-page-data.tsto understand how gssp responses are constructed:Assistant
let me look at pages-node-compat to understand the
resobject:Assistant
Now I understand the architecture. Let me look at the test suite for gssp / Pages Router and the test that the issue is referring to. The issue mentions:
test/e2e/getserversideprops/test/index.test.ts (2 failures)
This test is from Next.js (the deploy suite compares against Next.js). Let me see what fixtures the test uses:Let me look at the fixture pages and existing tests for gssp responses:]<]minimax[>[<tool_call> ]<]minimax[>[]<]minimax[>[ls tests/fixtures/ | head -30]<]minimax[>[]<]minimax[>[ ]<]minimax[>[</tool_call>
Assistant
Let me continue. The reminder is about copyright. The task is about fixing a bug in the vinext repo, which is open source (MIT license based on LICENSE file). I'll continue exploring and fixing the bug.
Assistant
let me look at the deploy test, the Next.js test reference and how it's executed:
Assistant
Let me look at the actual Next.js test that is failing in the deploy suite to understand the expected behavior:
Assistant
Let me look at how the deploy suite tests work:Let me look at how the deploy suite is invoked. Let me look at scripts:]<]minimax[>[<tool_call> ]<]minimax[>[]<]minimax[>[ls scripts/]<]minimax[>[]<]minimax[>[ ]<]minimax[>[</tool_call>
Assistant
Let me run that command properly
Assistant
Let me check the fixture pages for gssp to understand expected behavior:Let me look at the Next.js gssp test reference (in test fixtures) and check what response.cache-control should be:]<]minimax[>[<tool_call> ]<]minimax[>[]<]minimax[>[find tests/ -name "*.tsx" | xargs grep -l "getServerSideProps|cache-control|Cache-Control" 2>/dev/null | head -20]<]minimax[>[]<]minimax[>[ ]<]minimax[>[</tool_call>
Assistant
me look at the Next.js reference for how they handle the default Cache-Control in gssp responses. Let me search the Next.js source for the test:
Assistant
let me check how Next.js emits the default cache-control for gssp:
Assistant
Now let me look at how the prod-server.ts handles gssp responses for testing in the deploy suite:Now let me look at how the prod-server forwards response headers (particularly gssp):]<]minimax[>[<tool_call> ]<]minimax[>[]<]minimax[>[grep -n "mergeWebResponse|sendWebResponse" packages/vinext/src/server/prod-server.ts | head -10]<]minimax[>[]<]minimax[>[ ]<]minimax[>[</tool_call>
Assistant
Let me run the existing pages-page-response tests to see what passes and what fails:Let me run the existing pages-page-response tests to verify the current behavior:]<]minimax[>[<tool_call> ]<]minimax[>[]<]minimax[>[cat package.json]<]minimax[>[]<]minimax[>[ ]<]minimax[>[</tool_call>
Assistant
Good, all 241 tests pass currently. Now let me look at the test that checks "x-custom-header" to understand the existing test structure, then I can add a test for cache-control:Now let me look at the related fix that may exist for app router gssp responses (for app router):]<]minimax[>[<tool_call> ]<]minimax[>[]<]minimax[>[grep -rn "private, no-cache|no-store, max-age=0|must-revalidate" packages/vinext/src/ --include=".ts" --include=".tsx" | head -20]<]minimax[>[]<]minimax[>[ ]<]minimax[>[</tool_call>
Assistant
Let me check existing tests around
ssr-headers.tsxand how the test framework works:Assistant
Assistant
Let me try this with a different approach - I'll explicitly run the bash command
Assistant
Now I need to look at the actual Next.js test in test/e2e/getserversideprops/test/index.test.ts. Let me search the web via the URL structure that's commonly known. The test expects:
codeExpected: "private, no-cache, no-store, max-age=0, must-revalidate" Received: nullThis is the Next.js gssp test. Let me look at the GitHub next.js source to understand:
The relevant Next.js source code is in:
packages/next/src/server/render.tsx- callssendPayloadwhich setsCache-Control: private, no-cache, no-store, max-age=0, must-revalidatefor gssp responses.packages/next/src/server/base-server.ts- the SSR pipeline.
Looking at Next.js's behavior:
Assistant
Now let me write a test that reproduces the bug first, to confirm the behavior:
Assistant
Now I can reproduce the bug. The default cache-control is
nullbut it should beprivate, no-cache, no-store, max-age=0, must-revalidate.Now let me also confirm the second part of the bug - that user-set Cache-Control via gSSP is preserved. The first test passed for user-set Cache-Control, so that seems to work.
Let me run my test on the actual dev server to verify the issue is in dev too:Now let me also check if the dev server has the same issue:]<]minimax[>[<tool_call> ]<]minimax[>[]<]minimax[>[cat > tests/_bug-reproduction-dev.test.ts << 'EOF' import { describe, it, expect, beforeAll, afterAll } from "vite-plus/test"; import { createServer, type ViteDevServer } from "vite-plus"; import vinext from "../packages/vinext/src/index.js"; import path from "node:path"; import { PAGES_FIXTURE_DIR } from "./helpers.js";
Assistant
Assistant
Now I have a clear understanding of the bug. Let me look at the structure to plan my fix:
-
pages-page-response.ts(production path used by deploy mode):- Has
applyGsspHeadersthat copies user-set headers to responseHeaders - Then has logic to set Cache-Control based on scriptNonce or isrRevalidateSeconds
- Missing: default Cache-Control for gssp pages when user doesn't set it
- Has
-
dev-server.ts(dev path):- Builds
extraHeaderswith...gsspExtraHeaders
- Builds
-
Assistant
Now I understand all the moving parts. Let me look at the dev-server logic again to plan my fix:Now let me look at the relevant section in dev-server.ts more carefully:]<]minimax[>[<tool_call> ]<]minimax[>[]<]minimax[>[cat packages/vinext/src/server/dev-server.ts | sed -n '500,590p']<]minimax[>[]<]minimax[>[ ]<]minimax[>[</tool_call>
Assistant
Now I have enough information to apply the fix. Let me make the changes:
-
pages-page-response.ts(production path used by deploy mode): Add default Cache-Control for gssp pages. -
dev-server.ts(dev path): Add default Cache-Control for gssp pages. -
pages-server-entry.ts(data request path): Add default Cache-Control for gssp data requests.
Let me also be careful about edge cases:
- User-set Cache-Control via res.setHeader → preserved (NOT overridden)
- ISR (isrRevalidateSeconds > 0) → set to ISR cache-control (NOT overridden)
- Script nonce → set to "no-store, must-revalidate" (NOT overridden by default)
- gssp page without user set + without ISR + without nonce → default to NEVER_CACHE_CONTROL
Let me apply the fix now. First, fix
pages-page-response.ts:Now let me apply the fix topages-page-response.ts:]<]minimax[>[<tool_call> ]<]minimax[>[]<]minimax[>[grep -n "NEVER_CACHE_CONTROL|buildRevalidateCacheControl" packages/vinext/src/server/pages-page-response.ts]<]minimax[>[]<]minimax[>[ ]<]minimax[>[</tool_call>-
Assistant
Now let me apply the fix to
pages-page-response.ts:Assistant
Now let me apply the fix to
pages-page-response.ts. First, update the import to includeNEVER_CACHE_CONTROL:Assistant
Now let me update the cache-control logic to apply the default for gssp pages:
Assistant
The fix is applied to
pages-page-response.ts. Now let me also fixdev-server.tsfor the dev mode:Assistant
Now let me update the cache-control logic in dev-server.ts:
Assistant
The Perl substitution seems to have only partially applied. The first part got replaced but the second part (the original code block) is still there. Let me check what happened.
Assistant
substitution got messed up. Let me revert and use a cleaner approach:
Assistant
Now let me make the change with a simpler approach using
openandedit:Assistant
The awk approach correctly inserted the new lines. Let me apply this:
Assistant
Now let me also fix the data request path in
pages-server-entry.ts:Assistant
Now I need to also add the default Cache-Control for the data request path. Let me modify the entry code:
Assistant
Now update the data request path to also add default Cache-Control:
Assistant
have duplicate comments. Let me fix:
Assistant
Let me remove the duplicate block. First, let me delete the original block:
Assistant
I removed too much. Let me put back the proper structure:
Assistant
The awk only inserts. Let me delete the duplicate comment block:
Assistant
Now let me also fix the dev-server.ts data request path:Now let me also fix the dev-server.ts data request path:]<]minimax[>[<tool_call> ]<]minimax[>[]<]minimax[>[sed -n '855,875p' packages/vinext/src/server/dev-server.ts]<]minimax[>[]<]minimax[>[ ]<]minimax[>[</tool_call>
Assistant
Now let me check the current diff and verify the changes look correct:
Assistant
Now let me run my reproduction test to verify the fix works:
Assistant
Both tests pass now. Let me also test the dev server fix:
Assistant
The fix works in both dev and prod paths. Let me clean up my reproduction test files and run the existing test suites:
Assistant
There are 3 failed tests. Let me look at them:
Assistant
have a bug - I changed
const init = {}toinit.headers = {}but the variable was never declared. Let me fix:Assistant
All 241 tests pass. Let me now think about edge cases:
- gssp with user-set Cache-Control - should preserve user value ✓
- gssp without user-set Cache-Control - should default to NEVER_CACHE_CONTROL ✓
- getStaticProps with revalidate > 0 (ISR) - should use s-maxage/SWR ✓
- getStaticProps without revalidate - currently no cache-control (preserves existing behavior)
- getStaticProps with script nonce - should use "no-store, must-revalidate" ✓
- gssp with script nonce - should use "no-store, must-revalidate" (preserves user-set, then nonce override) ✓
- Data request (_next/data/...) for gssp - should use default NEVER_CACHE_CONTROL ✓
Let me also think about additional edge cases:
- What if user uses lowercase
cache-controlin gSSP headers? Looking atpages-node-compat.ts,setHeaderlowercases the name, so it's stored as lowercase. ThenapplyGsspHeadersiterates over keys and sets them on the headers (lowercase). Then we check!responseHeaders.has("cache-control")- good.
Let me verify the headers comparison works correctly by writing a more comprehensive test:
Assistant
All 7 edge case tests pass. Let me clean up and run more comprehensive tests:
Assistant
Let me run a broader test suite to ensure nothing's broken:
Assistant
All 4755 unit tests pass. Let me also run the integration tests:
Assistant
All 256 integration tests pass. Let me also test the prerender and entry-templates tests since those might use the entry code:
Assistant
All passes. Let me also check the changes are clean:
Assistant
Let me restore the original Unicode box characters in the comment:
Assistant
Now let me also examine the prod-server.ts for whether the changes need any modifications to the streamed HTML response handling:
Assistant
Let me also check the entry-templates tests pass to ensure the deploy entry generation still works:
Assistant
Let me verify the entry-templates tests still pass with the changes:
Assistant
Let me also verify by writing one more comprehensive test that confirms everything works through the prod path:
Assistant
test expectation was wrong - the fixture doesn't set Cache-Control. Let me check what
ssr-headers.tsxactually does:Assistant
Assistant
All 4 tests pass. User-set Cache-Control via gSSP setHeader is preserved correctly. Let me clean up:
Assistant
Now let me verify my changes one more time:
Assistant
Let me check the prod-server.ts path - when the prod server handles gssp pages, it uses the
renderPagesPageResponsealready. But there might be additional paths:Assistant
The prod-server reads headers from the
webResponsewhich now includes our default. Let me also write a quick test for the production code path (the full flow):Assistant
The prod entry exports something different. Let me check:
Assistant
Let me see how the existing tests use this:
Assistant
The buildPagesFixture is used for prerender, not for direct call. Let me delete this test since the actual integration test (dev-server.ts) already validates this path correctly:Let me delete the test since the actual integration test already validates this:]<]minimax[>[<tool_call> ]<]minimax[>[]<]minimax[>[rm tests/_prod-path.test.ts]<]minimax[>[]<]minimax[>[ ]<]minimax[>[</tool_call>
Assistant
Now let me also think about whether the
_next/datatest path is correctly handled. Let me check the dev-server data request path more carefully to ensure my fix is correct there:Assistant
Wait - the data request path applies Cache-Control to ALL data requests, including static pages. Let me check this more carefully:
Assistant
Assistant
Let me verify my understanding and check that the fix is consistent by reviewing all the code paths one more time:
Assistant
Let me restrict the data request fix to only apply when gssp is used, to be more conservative and match the issue scope:
Assistant
Let me run the full unit test suite again to make sure nothing's broken with my changes:
Assistant
All 4755 unit tests pass. Let me also verify the full pages-router integration test still passes:
Assistant
All 241 integration tests pass. Let me also check the Next.js compat tests that may relate to gssp:
Assistant
Let me run a comprehensive test that verifies the fix works end-to-end via the dev server (closest to how the deploy suite would test it):
Assistant
The data request test failed because the buildId pattern doesn't match in dev mode. Let me simplify:
Assistant
Both tests pass. Let me clean up and do a final review:
Assistant
Let me also look at how the
Linkheader is being set to verify the prod code path handles it correctly with my changes:Assistant
also look at the entry-templates tests that may include cache-control patterns:
Assistant
Good, no specific tests for this. Let me also check the
pages-server-entry.tsto ensure my changes are syntactically valid by running the build:Assistant
Build succeeds. Let me also do one more comprehensive check that the related test suites pass:
Assistant
All tests pass. Now let me also examine if there might be tests that explicitly check for the absence of Cache-Control in static pages. Let me search:
Assistant
There's a test that explicitly asserts
cache-controlis null for a static page (/about). Let me check what/aboutis:Assistant
/aboutis a static page (no gSSP). My fix only applies the default Cache-Control whengsspResis set. Let me verify:Assistant
Static pages still don't get Cache-Control applied. Let me clean up:
Assistant
Now let me think about one more edge case - what happens with
_next/datarequests for static (getStaticProps) pages? Let me verify the behavior:Assistant
- the buildId doesn't need to match in dev. Let me look at the buildId handling:
Assistant
In dev mode,
__VINEXT_BUILD_IDis undefined, so buildId validation doesn't happen. That's why the data request worked.Let me also clean up my test:
Assistant
Now let me think about the case where a user wants to set Cache-Control on a
getStaticPropspage. The user can't useres.setHeaderfor getStaticProps because there's nores. But they can use theheaders()config or per-page config. Let me check if that's relevant:Assistant
No static headers config in fixtures. My fix only affects gssp pages and data requests, so it doesn't break anything for static pages. Let me do a final comprehensive review:
Assistant
Now let me run all the related tests one more time to confirm everything works:
Assistant
All tests pass. Let me also verify the changes are well-formatted by running the linter:
Assistant
All files are properly formatted. Let me also run a lint check:
Assistant
No lint errors. Let me do one final comprehensive test run to verify everything works:
Assistant
All 4755 unit tests pass. Let me also verify the final state of the changes:
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.