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's write a quick reproduce script using the test harness in pages-router.test.ts to understand how tests invoke the render pipeline.
Assistant
We have actual Next.js source available. Let's search for the default Cache-Control constant for pages router SSR responses.
Assistant
Good, none. Now let's check pages-page-data.test.ts for gsspRes null case and static props without revalidate cache behavior.
Assistant
Now let's edit pages-page-response.ts.
Assistant
Now add the
hasStaticPropsoption field and update logic:Assistant
Now update the actual cache-control logic near the end of the function.
Assistant
Use the
editcommand with line numbers instead.Assistant
Now let's write a repro test using this production pattern against
/ssr-headersand/ssr.Assistant
Both scenarios work now. Let's clean up repro test files and also handle the dev-server.ts path for consistency (matching Next.js dev behavior would be
no-cache, must-revalidate, but let's check what Next.js actually does more carefully before changing dev-server.ts).Assistant
All 263 tests pass. Now let's run the broader test suite to check for regressions elsewhere (e.g., static export, cache-related tests, deploy tests).
Assistant
All pass. Now let's run the rest of the unit tests (excluding slow e2e playwright which likely aren't run here) to check for other affected areas like static-export, prerender, build/report.
Assistant
All pass. Let's also run remaining relevant test files quickly (build-report, standalone-build, seed-cache, tpr-kv-keys, prod-server-prerender-seeder, kv-cache-handler).
Assistant
All good. Let's check
git diffto review the final changes.Assistant
dist/ is gitignored (build artifact), so no need to update it manually. Let's verify no other places compute
applyGsspHeadersbehavior duplicated (e.g., pages-data-route.ts for_next/datarequests) that might also need similar defaults.Assistant
Type-check, lint, and formatting all pass. Let's do a final review of the diff and confirm no leftover temp files.
Assistant
Assistant
This resolves the issue: Pages Router
getServerSideProps(and plain, non-getStaticProps) responses now get the defaultCache-Control: private, no-cache, no-store, max-age=0, must-revalidateheader in the production/deploy build path, while explicitres.setHeader('Cache-Control', ...)overrides set insidegetServerSidePropsare preserved and forwarded to the final HTTP response. The change is minimal, scoped to the production render pipeline (pages-server-entry.ts+pages-page-response.ts), mirrors Next.js's ownhasStaticProps-gated default logic, and doesn't regress any existing ISR/cache/streaming/i18n/static-export test suites or type-checking.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.