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 statusor 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 what we're working with.
Assistant
Now let me find where gssp is actually dispatched. I see
applyGsspHeadersalready exists. Let me find the call site for it and look for wherePagesGsspResponseis created (which would be thegsspResobjectAssistant
Now let me find where
createGsspReqResis defined:Assistant
Let me look at the dev-server.ts to understand how getServerSideProps is being processed in dev mode:
Assistant
Now let me look at how Next.js handles the default Cache-Control header for gssp pages. Let me check Next.js itself for reference:
Assistant
Let me check the deploy mode:
Assistant
me look at the tests for pages-page-response:
Assistant
Now let me check the e2e tests related to getserversideprops:
Assistant
me look at how the deploy suite is configured:
Assistant
me check how the deploy tests work in the examples folder:
Assistant
Now let me look at the Next.js tests for
getserversidepropsto understand what's expected:Let me look at the Next.js test directory for the actual test:]<]minimax[>[<tool_call> ]<]minimax[>[]<]minimax[>[cd /vinext && find . -path "/test/e2e/getserversideprops" 2>/dev/null | head -5]<]minimax[>[]<]minimax[>[ ]<]minimax[>[</tool_call>Assistant
Let me retry that command:
Assistant
Let me look at the Next.js source for the default Cache-Control handling for gssp:
Assistant
Now I see the logic. The Next.js pages handler uses
res.getHeader('Cache-Control')to check if the user has already set the header, and only sets the defaultCache-Controlheader (viacacheControl = { revalidate: 0, expire: undefined }) if the user hasn't.The default value
revalidate: 0for gssp gets translated to: looking at thegetCacheControlHeader:Assistant
Now I see the logic clearly. Next.js sets
Cache-Control: private, no-cache, no-store, max-age=0, must-revalidatefor gssp pages, unless the user has already set their own Cache-Control header.Now let me look at the vinext
applyGsspHeadersfunction:Assistant
Now let me re-look at the test to understand what's expected. The issue says gssp responses lack Cache-Control. The test expects
private, no-cache, no-store, max-age=0, must-revalidatefor gssp pages and custom values set viares.setHeader('Cache-Control', ...).Let me look at the PagesGsspResponse and PagesMutableGsspResponse types:
Assistant
me search for the deploy mode flow:
Assistant
me search for Next.js's actual gssp tests to understand what they're testing:
Assistant
Next.js isn't checked out locally. Let me look at the AGENTS.md or other documentation to understand the testing approach. Let me look at e2e test setup
Assistant
Let me write a reproduction script first to confirm the bug:
Assistant
Good, the compiled JS exists. Let me create a more reliable reproduction script using the dist:
Assistant
confirmed the bug for case 1 and 3 (default Cache-Control is missing). Let me check the dev-server flow more carefully:
Assistant
Let me look at
streamPageToResponse:Assistant
me also check the prod-server.ts:
Assistant
Let me check the build script and understand the deploy entry path:
Assistant
Let me see how the deploy flow's worker entry uses the server:
Assistant
Let me check how vinext handles draft mode and whether scriptNonce affects gSSP:
Assistant
me also look at the test to confirm the existing behavior:
Assistant
Let me check if there are other paths where gSSP headers are processed in prod-server:
Assistant
Now I'll make the fix. Let me modify
pages-page-response.ts:Assistant
Now I'll apply the fix. Let me add the default Cache-Control header for gSSP responses:
Assistant
There's already a constant for this. Let me check it:
Assistant
Excellent!
NEVER_CACHE_CONTROLis already defined. Let me apply the fix:Assistant
Good. Now let me apply the fix to
pages-page-response.ts. First, I'll add the import forNEVER_CACHE_CONTROL:Assistant
Now let me modify the section that applies headers to add the default Cache-Control for gSSP responses:
Assistant
Now let me rebuild and test:
Assistant
Build successful. Now let me test the fix:
Assistant
All four cases pass now. Let me also run the existing tests for pages-page-response to make sure I didn't break anything:
Assistant
All 9 existing tests pass. Now let me check if there are other tests that might be affected by this change:
Assistant
me run the pages-page-data tests as well:
Assistant
Now let me check the dev-server for the same issue and fix it there too:
Assistant
I should also fix the dev-server. Let me understand how to detect if gSSP ran:
Assistant
Let me fix the dev-server.ts to also apply the default Cache-Control for gSSP responses:
Assistant
Let me add the import and the fix:
Assistant
Now let me look at the dev-server's extraHeaders block and add the fix. Let me first track when gSSP actually runs:
Assistant
Now I need to track whether gSSP actually ran. Let me modify the code:
Assistant
Now let me find the extraHeaders block and update it:
Assistant
I see I left some leftover code. Let me clean it up:
Assistant
Now let me check the dev-server isr-cache test setup:
Assistant
Good, the dev-server is fixed. Now let me build and verify both fixes work:
Assistant
All cases pass. Let me also run the existing tests to make sure they still pass:
Assistant
All 18 tests pass. Now let me also look at what other tests cover this area, especially the dev-server tests:
Assistant
Let me also check the dev-server tests to ensure the change doesn't break anything:
Assistant
Now let me run more comprehensive tests to make sure I haven't broken anything:
Assistant
All tests pass. Now let me also write a more comprehensive reproduction script to check edge cases:
Assistant
All edge cases pass. Now let me run the full unit test suite to make sure nothing else is broken:
Assistant
All 4755 unit tests pass. Let me also run the integration tests:
Assistant
Let me try running just the pages-router tests since those are most relevant:
Assistant
All 241 tests pass! Let me also check the features tests:
Assistant
All tests pass. Let me also check the api-handler tests since gSSP is related:
Assistant
document.test.ts is a unit test. Let me run that:
Assistant
me also check the deploy tests since those are related to the failing tests:
Assistant
Let me also run pages-router-concurrency to make sure my changes don't affect it:
Assistant
check the failing tests:
Assistant
Let me check if these failures are pre-existing by reverting changes:
Assistant
:
Assistant
2 are pre-existing failures (unrelated to my changes). Let me restore my changes:
Assistant
The failures are timeouts in
revalidateTagandrevalidatePathtests - these are timing-sensitive tests unrelated to my changes. The output is just 1 of the failures showing timeout. These tests fail without my changes too.The test output is very long. Let me check the final summary line
Assistant
me verify the full build is clean:
Assistant
All checks pass. Now let me also look at whether there are tests that exercise my specific change in dev mode by running the full pages-router test suite:
Assistant
All 10 getServerSideProps tests pass. Let me look at what test cases exist for headers:
Assistant
also check related tests for ISR and headers:
Assistant
All 21 header-related tests pass. Now let me also look at the issue summary to make sure my fix is complete:
Assistant
also check for edge cases by looking at the data flow in pages-page-data.ts:
Assistant
Let me run the reproduction script one more time to confirm the fix works:
Assistant
All edge cases pass. Let me also run a comprehensive test to check for any regressions:
Assistant
All 301 tests pass. Let me clean up my test files:
Assistant
Let me also make sure I haven't introduced any unused imports:
Assistant
Imports are used. Let me also check for
gsspRanvariable is used:Assistant
Good. Let me also check that my changes don't introduce any dead code or unused exports:
Assistant
All checks pass. Let me also do a final review of the diff:
Assistant
The fix is complete. Let me do a final verification by running the complete test suite that I touched:
Assistant
All 567 tests pass. Now let me address the checklist:
Checklist
✅ If an error was reported in the issue description, I have successfully reproduced it.
I created a reproduction script that confirmed the bug:
- Case 1 (gSSP, no user Cache-Control): Before fix:
cache-control: null. After fix:cache-control: private, no-cache, no-store, max-age=0, must-revalidate✓
- Case 1 (gSSP, no user Cache-Control): Before fix:
Assistant
The fix is complete. Let me submit my changes:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.