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.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.
- Assistant
Let me write a quick repro against the built pages entry:
- Assistant
Now I understand the structure. Let me check for any existing tests asserting absent Cache-Control that my change could break:
- Assistant
Now the
_next/dataJSON path in the pages server entry. Let me look at how that entry template imports helpers: - Assistant
Now fix the
_next/databranch in the entry template. First add the cache-control import: - Assistant
Now update
buildNextDataJsonResponseto handleHeadersinstances (the current object-spread would silently drop them): - Assistant
Now add a fixture page that overrides Cache-Control:
- Assistant
Now add unit tests to
tests/pages-page-response.test.ts: - Assistant
Now add integration tests to the production server suite:
- Assistant
Now run the surrounding test files to check for regressions:
- Assistant
While that runs, check the dev-server
_next/datapath for the same dropped-headers bug: - Assistant
All 245 pages-router tests pass. Run the broader pages/deploy-related suites:
- Assistant
Resource contention with the background run — I'll retry checks after tests finish.
- Assistant
All 459 pass. Now retry the repo check (lint + typecheck + format):
- Assistant
The diff is clean. Waiting on the prerender suite results:
- Assistant
All green. Summary of the fix:
Root causes
- Missing default header (the 2 deploy-suite failures):
renderPagesPageResponse(packages/vinext/src/server/pages-page-response.ts) only setCache-Controlfor CSP-nonce responses and ISR pages. Plain gSSP pages got no header at all. - Dropped
res.setHeadervalues on_next/datarequests: the generated pages entry readgsspRes.headers, which doesn't exist — the node-compat res only exposesgetHeaders()— so all gSSP headers/cookies were silently dropped from data responses (a latent bug from #1412).
Changes
packages/vinext/src/server/pages-page-response.ts— afterapplyGsspHeaderscopies user headers into the response, gSSP pages now default toprivate, no-cache, no-store, max-age=0, must-revalidate(NEVER_CACHE_CONTROL) unless the user already setCache-Control. Mirrors Next.jssendRenderResultwith gSSP'scacheControl: { revalidate: 0 }. User overrides win; nonce/ISR branches are untouched.packages/vinext/src/entries/pages-server-entry.ts— the_next/databranch now readsgsspRes.getHeaders(), forwards multi-valueSet-CookieviaHeaders.append, and applies the same never-cache default when the user didn't set one.packages/vinext/src/server/pages-data-route.ts—buildNextDataJsonResponsebuilds headers via theHeadersconstructor (object spread would drop a passed-inHeadersinstance) and forcesContent-Type: application/jsonfor the data endpoint.tests/fixtures/pages-basic/pages/ssr-custom-cache.tsx— new fixture mirroring Next.js'custom-cachepage (res.setHeader("Cache-Control", "public, max-age=3600")).
Tests (reproduced failing, now passing)
- Unit (
tests/pages-page-response.test.ts): default applied for gSSP, user override preserved, no default for non-gSSP pages. - Integration (
tests/pages-router.test.ts, full prod-server path): default + override on HTML responses, default + override on_next/dataresponses, and gSSP header/cookie forwarding to data responses.
Verification
tests/pages-router.test.ts: 245 passed;pages-page-response: 12 passed- Related suites (
pages-data-route,pages-data-url,pages-page-data,entry-templates,cache-control,pages-i18n,pages-i18n-prod,features,pages-router-concurrency,request-pipeline,prerender,prod-server-prerender-seeder): 625 passed, 0 failed pnpm check(format + lint + typecheck): clean
- Missing default header (the 2 deploy-suite failures):
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
- composer-2.5Compare side by side →
- composer-2.5Compare side by side →
- composer-2.5Compare side by side →
- composer-2.5Compare side by side →
- composer-2.5Compare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- fable-5Compare side by side →