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.Expected: "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 callsubmit) usinggit statusorgit diffcommands. However you don't need to usegit addorgit commitbefore submitting your changes. In fact,submitonly submits currently unstaged changes because it usesgit diffto get the changes that need to be submitted.CHECKLIST
Before submitting your solution, please go over the following checklist and make sure you've done everything:
- If an error was reported in the issue description, I have successfully reproduced it.
- If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- I have thought about edge cases and made sure my fix handles them as well.
- I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.
Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!
(Current directory: /vinext, current file: none) bash-$
- Assistant
I'll start by exploring the repository structure to understand the codebase and locate relevant files. Let me first get an overview.
- Assistant
Let me understand the repository structure better. This appears to be a Next.js-related project (vinext) that's a deploy suite. Let me look for the test file mentioned in the issue.
- Assistant
Let me look at the tests directory structure to find the test mentioned in the issue.
- Assistant
Let me look for tests related to getServerSideProps or gssp.
- Assistant
Let me look for the test file mentioned in the issue.
- Assistant
That path doesn't exist in this repo. The issue mentions tests from the Next.js Deploy Suite (vinext). Let me look for tests related to "cache-control" and "gssp" to understand the problem better.
- Assistant
Let me look at the cache-control test file and pages-router test file to understand the issue better.
- Assistant
Let me look at the pages-page-response.test.ts file to understand how pages router responses are tested.
- Assistant
Now let me look at the pages router test and related source files to understand the gssp handling.
- Assistant
Let me look at the deploy test file to understand how deploy mode handles gssp responses.
- Assistant
Let me explore the source code for gssp handling in the server code to understand the issue better.
- Assistant
Let me look at the pages-page-response.ts file to see how gssp responses are handled.
- Assistant
Let me look at the prod-server.ts to understand how gSSP responses are handled in production.
- Assistant
Let me look at the pages-server-entry.ts to understand how gSSP responses are dispatched.
- Assistant
Now I need to understand the issue. Let me look at the pages-page-data.ts to see how gSSP responses are created.
- Assistant
Let me look at the
pages-node-compat.tsto see how theresobject is created forgetServerSideProps. - Assistant
Now let me look at the dev-server.ts to see how gSSP responses are handled in development.
- Assistant
Now I understand the issue. Let me look more closely at how the gSSP cache-control is handled in the dev-server.ts. Let me search for where gsspExtraHeaders are built.
- Assistant
Let me look at the relevant section of dev-server.ts where gsspExtraHeaders are set and the cache-control handling.
- Assistant
Let me look at the section where Cache-Control is set for gSSP responses in dev-server.ts.
- Assistant
Now I understand the issue. Let me look at the pages-page-response.ts more closely to see the Cache-Control logic after gSSP headers are applied.
- Assistant
Let me check the test for pages-page-response.ts to understand what the expected behavior should be.
- Assistant
Now I have a clear understanding of the issue. Let me examine the dev-server.ts more carefully to see how gSSP headers are handled.
- Assistant
Now I have a clear understanding of the issue. Let me examine the test files to understand the expected behavior better.
- Assistant
Now I have a clear understanding of the issue. Let me trace through the code flow to understand exactly what's happening:
-
In
pages-page-response.ts: TheapplyGsspHeadersfunction merges headers fromgSSPresponses but does NOT set a defaultCache-Controlheader. After it runs, only ISR/script-nonce Cache-Control is applied, leaving gSSP responses without any Cache-Control header. -
In
dev-server.ts: Similarly, gSSP headers are collected but no default Cache-Control is set for gSSP pages.
The fix needs to:
- Set a default
Cache-Control: private, no-cache, no-store, max-age=0, must-revalidatefor gSSP pages when the user hasn't explicitly set one - Preserve user-set Cache-Control headers from
res.setHeader()
Let me first look at the dev-server.ts more closely to understand the gSSP handling there.
-
- Assistant
Let me look at the test file to understand what the expected behavior should be for gSSP pages.
- Assistant
Let me look for e2e tests related to getServerSideProps.
- Assistant
Let me look for tests that check Cache-Control header for gSSP responses in the e2e tests.
- Assistant
Let me look at the e2e tests related to pages router ISR to understand the expected behavior.
- Assistant
Let me look at how gSSP responses are handled in the dev-server.ts more closely.
- Assistant
Let me look at how
isrRevalidateSecondsis determined in dev-server.ts to understand if gSSP pages are always ISR or not. - Assistant
Now I have a clear understanding of the issue. Let me trace through the code:
-
In
pages-page-response.ts, whengsspResis present (getServerSideProps was called), headers from the gSSP response are merged, but no default Cache-Control header is set for gSSP pages. -
After
applyGsspHeaders, Cache-Control is only set for:scriptNonce→"no-store, must-revalidate"isrRevalidateSeconds→ ISR cache control- Otherwise: no Cache-Control at all!
-
In
dev-server.ts, the same issue exists - gSSP headers are collected but no default Cache-Control is set for gSSP pages.
The fix needs to:
- Set default
Cache-Control: private, no-cache, no-store, max-age=0, must-revalidatefor gSSP pages when user hasn't set one explicitly - Preserve user-set Cache-Control headers from
res.setHeader()
Let me first check the pages-node-compat.ts to understand how the
resobject works. -
- Assistant
Let me check how the dev-server.ts handles gSSP cache-control to see if it's also missing the default.
- Assistant
Now I have a clear understanding of the issue. Let me look at the prod-server.ts to see how gSSP responses are handled there.
- Assistant
Let me look at the prod-server.ts more carefully to see how it handles pages router responses.
- Assistant
Let me look at the prod-server.ts more closely for how it handles pages SSR.
- Assistant
Now I have a clear understanding of the issue. Let me trace through the code flow:
-
In
pages-page-response.ts, theapplyGsspHeadersfunction copies headers from the gSSP response to the output headers. However, it does NOT set a defaultCache-Controlheader for gSSP pages. -
After
applyGsspHeaders,Cache-Controlis only set for ISR pages (whenisrRevalidateSecondsis set) or for script nonce pages. For regular gSSP pages (non-ISR, non-nonce), NOCache-Controlis set. -
In
dev-server.ts, gSSP headers are collected ingsspExtraHeaders, but no defaultCache-Controlis set for gSSP pages. -
Next.js sets the default
Cache-Control: private, no-cache, no-store, max-age=0, must-revalidatefor all gSSP pages.
The fix needs to:
- In
pages-page-response.ts: AfterapplyGsspHeaders, ifgsspResis not null and noCache-Controlwas set by the user, set the default. - In
dev-server.ts: After collectinggsspExtraHeaders, if noCache-Controlwas set by the user and this is a gSSP page, set the default.
Let me also check the test expectations. Let me look at the dev-server.ts to understand the full picture:
-
- Assistant
Now I have a clear understanding of the issue. Let me create a reproduction script first to verify the issue exists.
- Assistant
Let me run the existing tests first to understand the current state.
- Assistant
Let me check what test runner they use.
- Assistant
Let me look at the vitest config to understand how to run tests.
- Assistant
Let me run the specific unit test with the right command.
- Assistant
Let me try running the test differently.
- Assistant
Let me try to figure out how to run the tests in this project.
- Assistant
Let me try to find how to run the tests.
- Assistant
Let me try running it directly with vitest.
- Assistant
Let me look at the vite config to understand the test project structure.
- Assistant
Let me understand the issue better. The problem is that when serving gSSP (getServerSideProps) responses, the Cache-Control header is missing. Let me look at the key code paths:
- In
pages-page-response.ts, theapplyGsspHeadersfunction merges headers from gSSP responses but doesn't add default Cache-Control - In
dev-server.ts, after calling getServerSideProps, gSSP headers are collected but default Cache-Control is not added
The fix needs to:
- When there's a gSSP response (
gsspResis not null), set the defaultCache-Control: private, no-cache, no-store, max-age=0, must-revalidateunless the user already set it - Preserve any user-set Cache-Control headers from
res.setHeader()
Let me now look at the exact place where we need to make changes.
- In
- Assistant
Now I understand the issue. Let me trace through the full code flow:
In
pages-page-response.ts:applyGsspHeaders()copies headers from gSSP response (including user-set Cache-Control) - this works fine- After that, Cache-Control is only set for
scriptNonceorisrRevalidateSecondspages - For regular gSSP pages (no ISR, no nonce), NO Cache-Control is set!
In
dev-server.ts:- gSSP headers are collected in
gsspExtraHeaders- user-set headers are preserved - Cache-Control is only set for
isrRevalidateSecondspages - For regular gSSP pages, NO Cache-Control is set!
The fix is to:
- In
pages-page-response.ts: After applying gSSP headers, ifgsspResis not null and no Cache-Control is set, add the default gSSP Cache-Control - In
dev-server.ts: After collecting gSSP headers, if it's a gSSP page and no Cache-Control is set, add the default
Let me implement the fixes:
- Assistant
Let me open the file properly.
- Assistant
Now I can see the exact issue. In
pages-page-response.ts, afterapplyGsspHeadersruns (line 377), Cache-Control is only set for:- Pages with
scriptNonce(line 379-380) - Pages with
isrRevalidateSeconds(lines 381-386)
For regular gSSP pages (non-ISR, non-nonce), NO Cache-Control is set at all!
The fix needs to add the default gSSP Cache-Control when:
gsspResis not null (it's a gSSP page)- No Cache-Control was already set (neither by user nor by ISR/scriptNonce logic)
Let me implement the fix in both files:
- Pages with
- Assistant
Let me try with the edit command syntax properly.
- Assistant
Let me use the correct edit command syntax.
- Assistant
Let me use sed to make the edit.
- Assistant
Let me verify the edit was correct.
- Assistant
The sed command didn't produce the correct result. Let me fix it properly.
- Assistant
Let me use a Python script to make the edit properly.
- Assistant
Let me use the edit command properly.
- Assistant
Let me write the script to a file first to avoid shell escaping issues.
- Assistant
Let me verify the edit.
- Assistant
The edit looks correct. Now I need to fix the same issue in the
dev-server.ts. Let me look at the exact location where I need to add the fix. - Assistant
Now I need to apply the same fix to the
dev-server.ts. After the ISR Cache-Control block, I need to add the default gSSP Cache-Control when no Cache-Control was set by the user and it's a gSSP page. - Assistant
Let me verify the edit.
- Assistant
Both edits look correct. Now let me run the relevant unit tests to verify the changes.
- Assistant
The tests are timing out. Let me try with a more direct approach.
- Assistant
Let me try a different approach. Let me check if there's a node-based test runner.
- Assistant
Let me try running the test differently.
- Assistant
Let me check what's available for running tests.
- Assistant
Let me try to find the right way to run tests in this project.
- Assistant
The test runner is
vp(vite-plus). Let me use that. - Assistant
Good, the existing tests pass. Now let me check if there are any tests that specifically test the gSSP Cache-Control behavior. Let me look at the pages-page-response test file again more carefully.
- Assistant
Let me look at the first test in the file to see if it has gSSP and no ISR.
- Assistant
The first test has
gsspReswith headers but doesn't check Cache-Control. My fix should add the default Cache-Control for that case. Let me verify my fix works correctly by running all the tests. - Assistant
Good, the tests pass. Now let me run the dev-server related tests to make sure my changes there don't break anything.
- Assistant
Let me also run the request-pipeline test which handles cache-control headers.
- Assistant
Let me run a broader set of unit tests to make sure nothing is broken.
- Assistant
All 170 test files passed (4755 tests). My changes don't break any existing tests. Let me also check if there are any other code paths that need the same fix. Let me look at the data route handler for gSSP JSON responses.
- Assistant
Let me check if there's a data route that also needs the fix.
- Assistant
Let me check how the data route builds the JSON response.
- Assistant
Let me look at the
buildNextDataJsonResponsefunction. - Assistant
Let me also check how the dev-server.ts handles gSSP data requests (/_next/data/...).
- Assistant
Let me look at the data request handling in dev-server.ts.
- Assistant
I see there's also the data request path (for
/_next/data/...requests) that might need the same fix. Let me also check the pages-server-entry.ts for the data request path. - Assistant
Let me look at the pages-server-entry.ts for how gSSP data requests are handled and see if there's the same issue.
- Assistant
Let me look at the
_next/datapath in the pages-server-entry.ts to see if it also needs the fix. - Assistant
Now I see there's also the
_next/dataJSON envelope path in the worker entry. Let me also check if that needs the default Cache-Control. Let me also look at how this works in the prod-server for gSSP data requests. - Assistant
The data request path (
_next/data/...json) for gSSP pages also needs the default Cache-Control. Let me fix that too. First, let me look at the data request path in the pages-server-entry.ts: - Assistant
Actually, wait. The issue is specifically about the HTML response for gSSP pages, not the data request path. Let me reconsider. The data request path (
_next/data/...json) returns JSON, and the test failure is about the HTML page Cache-Control header. Let me revert the pages-server-entry.ts change since it's not needed for this issue. - Assistant
Now let me verify the current state of my changes and run the tests again.
- Assistant
Good. Let me also check the dev-server.ts changes.
- Assistant
Both changes look correct. Let me also check if the
_next/datarequest path in dev-server.ts needs the same fix. - Assistant
The dev-server.ts
_next/datapath doesn't set a default Cache-Control either, but the issue is specifically about the HTML page response. Let me now run the full unit test suite to make sure everything is working correctly. - Assistant
All 170 test files pass (4755 tests). My changes don't break any existing tests. Let me also check if the
_next/datarequest path in the pages-server-entry.ts (production) needs the same fix. - Assistant
Now I need to also apply the fix to the
_next/dataJSON response path in the pages-server-entry.ts (production worker). Let me also fix the dev-server.ts data request path. - Assistant
Let me verify all the changes are correct.
- Assistant
Let me verify all the changes look correct.
- Assistant
The changes look correct. Let me run the full test suite one more time to make sure everything is working correctly.
- Assistant
All 170 test files pass (4755 tests). My changes don't break any existing tests. Let me clean up the temporary files.
- Assistant
I need to submit my changes now. Let me clean up temporary files and then submit.
- Assistant
Now let me verify the final state of my changes before submitting.
- Assistant
Now let me verify the final state of my changes one more time.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.5-35B-A3BCompare side by side →