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
This is dev server mode probably. Let's just run the existing test for ssr-headers and add a temp check for cache-control via a quick reproduce script.
Assistant
This is dev mode. Let's write a quick script to start the fixture server and query /ssr and /ssr-headers for Cache-Control header.
Assistant
Good, that runs fine. Now let's temporarily add a console.log inside the test file to check cache-control header (without committing it as a real test - I'll revert after).
Assistant
Confirmed:
/ssr(getServerSideProps page) currently returnscache-control: null. Now let's check/ssr-headerstoo, and restore the file after.Assistant
Now let's add the flag and set default cache-control. First view surrounding code fully to edit precisely.
Assistant
Let's use the
edit/replacetools instead for precision. First open the file at relevant line.Assistant
Now let's set
usedGetServerSideProps = trueinside the getServerSideProps block, and find the extraHeaders build section.Assistant
Now let's find the extraHeaders build section (around line ~1058 before edit, now shifted).
Assistant
Not imported yet. Let's add the import and the logic.
Assistant
Now let's add the logic in the extraHeaders section.
Assistant
Now let's also handle the
_next/dataJSON endpoint path in dev-server.ts (around line 860-870) to ensure default Cache-Control is applied there too.Assistant
Now let's use
editwith explicit line ranges.Assistant
Now let's fix the
pages-page-response.tsfor the prod/worker path too.Assistant
Now let's find and edit the
responseHeadersblock.Assistant
Now let's add an import for NEVER_CACHE_CONTROL and add path constant.
Assistant
Good, now the const path list is correct. Now add the import line in the generated template code.
Assistant
Now update the isDataReq block to use getHeaders() and add default Cache-Control.
Assistant
There's an extra duplicate closing brace at line 734. Let's remove it.
Assistant
Good, that's fixed now. Let's double check the whole isDataReq block once more for correctness.
Assistant
Both now show the default
NEVER_CACHE_CONTROL. Now let's verify user-set override still works, by temporarily modifying the ssr-headers fixture page to set a custom Cache-Control and confirming it sticks (dev-server path).Assistant
User override preserved in dev mode. Now let's restore fixture file and remove debug logs, and test the production build path (worker/pages-server-entry.ts).
Assistant
Now let's find prod tests that exercise the built pages-server-entry.ts (worker) path, e.g. pages-router-prod tests.
Assistant
I accidentally deleted the
_isrCachePathline. Let's fix.Assistant
Now let's rebuild.
Assistant
Good, compiles cleanly. Now let's build the fixture and start the prod server to test.
Assistant
Good, that's the correct build command (
vp pack). These warnings are pre-existing/unrelated. Let's confirm dist reflects our fix now, then rebuild the fixture.Assistant
Now let's also check
pages-page-response.jsdist reflects fix.Assistant
Now let's rebuild fixture and restart the prod server.
Assistant
Now let's find the actual buildId to test the
_next/dataJSON endpoint too.Assistant
All three paths (Node prod server HTML, gssp headers override preserved, and
_next/dataJSON) work correctly. Let's also verify the ssr-headers override still holds in prod build with a temp modification.Assistant
Override preserved in prod mode too. Now let's clean up test artifacts and restore fixture file.
Assistant
Good, no diff on fixture file. Let's check overall git status now.
Assistant
All 456 tests pass. Now let's run the full test suite to be thorough.
Assistant
Still running. Let's wait more.
Assistant
All 212 test files pass (6218 tests passed, 4 skipped — pre-existing skips, not failures). Now let's clean up leftover build artifacts and temp files.
Assistant
dist is gitignored, so it's fine to leave but let's clean it up anyway for tidiness.
Assistant
Let's do a final review of the full diff.
Assistant
This is a clean, minimal, well-targeted fix. Let's run the previously identified targeted tests one more time to double confirm everything works after final cleanup.
Assistant
All good (the stderr is an expected intentional error log from that test, not a failure). Let's also double check
pnpm/vp checktype-check passes for the whole repo since we touched generated code strings.Assistant
Everything passes cleanly: formatting, lint, and type checks. Let's do a final git status check before submitting.
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.