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's check next.js's actual source for this default cache-control logic.
Assistant
Not this one. Let's check line 1657.
Assistant
Now let's check the cloudflare-pages-router test dir for existing patterns, and check fixture pages for gssp usage of setHeader.
Assistant
Now let's edit the main branch logic:
Assistant
Good, so it does use the shared renderPagesPageResponse function for HTML. Let's check the JSON data route path bug regarding
gsspRes.headers.Assistant
Let's open around line 700-725 to edit properly, being careful this is inside a template literal.
Assistant
Good — indeed it's one big template literal (7 backtick occurrences: comments with escaped backticks plus start/end). My added lines correctly used ``` escaping consistent with existing style. Let's verify the whole file's syntax integrity by checking backtick counts.
Assistant
Good, the template literal starting at line 207 closes at line 838, and my added lines are within, with correctly escaped backticks. Now let's build the package to catch any TypeScript errors.
Assistant
No errors. Now let's run existing unit tests for pages-page-response and pages-page-data.
Assistant
That's fine, full unit suite passed. Now let's write a temporary script to verify the fix behaviorally by exercising
renderPagesPageResponsedirectly, and also verify pages-server-entry generated code via an actual e2e-style build test.Assistant
Both scenarios pass. Now clean up temp test and check the actual e2e pages-router test suite for gssp-related fixture pages, potentially add a fixture page + spec test matching the issue's recommendation (in vinext's own suite). Let's check existing fixtures for something similar to build on.
Assistant
Good, no test files were modified. Let's view full diff so far.
Assistant
Now let's do an actual integration test using the real build pipeline (without modifying test files) by writing a temporary standalone script that builds the pages-basic fixture and hits
/ssrand/ssr-headersto confirm real end-to-end behavior, then delete it.Assistant
Let's place the script inside the repo temporarily instead so module resolution works.
Assistant
Now let's find where
gsspExtraHeadersgets applied (streamPageToResponse) and where final Cache-Control gets set at the end of the dev-mode SSR render path.Assistant
Let's add the import and implement the fix.
Assistant
Now let's edit the extraHeaders block.
Assistant
Let's edit this section to add the default Cache-Control for gSSP.
Assistant
There's a stray extra
}at line 1087. Let's remove it.Assistant
Good, brace fixed. Now let's run tsc check for this file too.
Assistant
Now let's rerun our temp e2e test.
Assistant
Both the default and existing custom-header page now report the correct
Cache-Control. Now let's add an explicit override test usingres.setHeader('Cache-Control', ...)to make sure it's preserved (since ssr-headers doesn't set that header itself).Assistant
Override preserved. Now let's also verify the production build path (
generateServerEntry) works for both default and override, usingbuildPagesFixture+ running the built bundle, matching how the deploy suite likely operates.Assistant
Build succeeded. Now let's start the production server and hit endpoints.
Assistant
Now dist should reflect the changes. Let's re-verify.
Assistant
Now let's kill the old server, rebuild the fixture, and restart.
Assistant
All paths (HTML production, HTML dev, and
_next/dataJSON) now correctly emit the default and preserve overrides. Let's clean up server, temp files, and fixture artifacts.Assistant
Clean. Now let's also revert the
dist/build artifacts under packages/vinext (since we rebuilt viavp packearlier andtsc, these are gitignored likely, but let's check).Assistant
Good, gitignored. Now let's run the full unit test suite once more to make sure everything (including dev-server related tests) still passes.
Assistant
All 4755 tests pass. Let's also run the integration test project to be safe.
Assistant
All relevant tests (except the browser-launch one, which fails due to missing browser binary unrelated to our change) pass. Now let's view the final diff.
Assistant
This diff is clean and focused. Let's do a final overall sanity check — rebuild dist once more and confirm nothing else references the stale build state, then clean up any leftover build artifacts from our testing.
Assistant
All gitignored — no stray tracked changes. Final diff is clean and minimal. Let's review the checklist explicitly.
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.