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
Now let me look at the entry template's imports and the data-request section:
- Assistant
Now let me check the e2e prod test setup:
- Assistant
Now I'll implement. First,
pages-page-response.ts: - Assistant
Now add unit tests. First check the existing data-route tests:
- Assistant
Now add tests to
pages-page-response.test.tsfor the Cache-Control default/override: - Assistant
Run the unit tests:
- Assistant
Now check integration tests that exercise the built entry's
_next/datapath: - Assistant
Add the fixture page:
- Assistant
Now add the e2e assertions to
production.spec.ts: - Assistant
All checks pass. Now run the pages-router-prod e2e suite to verify end-to-end:
- Assistant
Browsers aren't installed. Install and retry:
- Assistant
All four endpoints correct. Kill the manual server and re-run the e2e suite:
- Assistant
Now run the broader unit test suites that touch pages routing and the dev server, plus deploy tests:
- Assistant
Add a deploy-mode assertion to the Cloudflare workers spec (the path closest to the failing deploy suite):
- Assistant
All Workers e2e tests pass. Run the full unit/integration suite to check for regressions:
- Assistant
While that runs, let me review the full diff:
- Assistant
knip passes. Let me check on the full test suite run:
- Assistant
The diff is clean. Waiting for the full suite to finish.
- Assistant
The full test suite re-run is in progress in the background (it takes ~8 minutes). I'll report the final result when it completes.
Summary of the fix so far:
The deploy suite failures came from two gaps in the Pages Router prod/deploy path:
-
Missing default
Cache-Controlon gSSP responses —renderPagesPageResponse(packages/vinext/src/server/pages-page-response.ts:396) never set a header for gSSP pages. It now emits Next.js' defaultprivate, no-cache, no-store, max-age=0, must-revalidateunless the user set one viares.setHeader(). -
All gSSP headers dropped on
_next/dataJSON requests — the generated pages server entry readgsspRes.headers, a property that doesn't exist (the res object exposesgetHeaders()), so user-set headers, cookies, and status codes were silently discarded. The data path now reuses the sharedapplyGsspHeaders()helper, forwards the gSSP status code, and applies the same never-cache default.
Verified against a real prod build —
/ssr,/custom-cache, and both_next/dataendpoints now return the expected headers, data requests are unchanged, and gSSP status/cookie forwarding on data requests works (201 + on ). -
- Assistant
I'll wait for the monitor to fire when the suite finishes.
- Assistant
Waiting for the suite to complete.
- Assistant
All 16 pass in isolation (in ~5s vs. the 90–240s timeouts under load) — the full-run failures were resource-contention timeouts in unrelated build-heavy tests, not regressions. Everything relevant to this change is green.
- Assistant
That monitor is no longer needed — the full-suite run it was watching already completed, and I've since confirmed the only failures were load-induced timeouts by re-running those five files in isolation (all 16 tests passed). The fix is complete and verified; no further action required.
- Assistant
That's just the leftover wait-loop finishing — all background tasks are now done. The work stands as summarized: both Cache-Control bugs fixed (default gSSP header +
_next/dataheader/status/cookie forwarding), with unit, e2e prod-server, and workerd deploy-mode coverage all passing.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.