Pages Router: gssp/getStaticProps responses missing default and user-set Cache-Control…
- User
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.
- Assistant
Let me look at the actual Next.js test file this issue references, to match the exact expectations.
- Assistant
Let me check how Next.js applies this header in
base-server.tsto match semantics (dev vs prod, data requests): - Assistant
Semantics confirmed. Now let me check for existing unit tests of
pages-page-responseand look at the prod-server test sections where I'll add e2e coverage: - Assistant
Now the default Cache-Control for gssp HTML responses:
- Assistant
Now fix
buildNextDataJsonResponseso aHeadersinit (with multipleset-cookie) is honored instead of being object-spread away: - Assistant
Now let me check the prod
_next/datatest section and existing dev-mode data tests to see what assertions exist: - Assistant
Safe to add a fixture page. Creating it now:
- Assistant
Now add unit tests to
pages-page-response.test.ts: - Assistant
Now update
pages-data-route.test.tsfor the Headers-init behavior: - Assistant
Now add e2e tests to the production server section of
pages-router.test.ts: - Assistant
All 4 new integration tests pass. Now run the full test file plus related suites to check for regressions:
- Assistant
All green. Final review of the complete diff:
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.