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 me explore the repository structure to understand the codebase.
Assistant
Let me explore the packages structure.
Assistant
Let me look at the pages-page-response.ts and pages-page-data.ts to understand how the gssp response and Cache-Control header is handled.
Assistant
Let me look at the pages-page-response.ts file to understand how the response is built.
Assistant
Let me look at the cache-control.js file to understand existing helpers.
Assistant
Let me look at the createGsspReqRes implementation and how the gsspRes is built.
Assistant
Let me find
__createPagesReqResand__renderPagesPageResponseimplementations.Assistant
Let me look at the test suites in vinext related to gssp.
Assistant
Let me look at the existing fixture for pages-router-prod to understand the structure and add a test. But first, let me understand the existing test for cache-control to see how the default Cache-Control should work.
Let me check the cache-control.test.ts.
Assistant
Now let me look at the pages-page-response.test.ts to understand how
renderPagesPageResponseis tested.Assistant
Let me look for the Next.js reference test for getserversideprops.
Assistant
Let me look at the request-apis.test.ts which might test gssp Cache-Control behavior.
Assistant
Let me look at the deploy.test.ts to understand the deploy mode testing and check how the gssp response is tested in deploy mode. The issue mentions "deploy mode" and "deploy suite". Let me look at the deploy test.
Assistant
Let me look at the fixtures used for e2e pages-router-prod tests, particularly the ssr page.
Assistant
The pages-router-prod tests use the
pages-basicfixture. Let me look at the pages-basic fixture, particularly the ssr page.Assistant
Now I understand the structure. Let me write a reproduction test to confirm the bug. Let me create a temporary test.
Assistant
Let me find out how tests are run in this repo.
Assistant
Let me look at the pages-data-route.ts for the data request path.
Assistant
Let me check the prod-server.ts and dev-server.ts to understand the rendering path for deploy mode.
Assistant
So
renderPagesPageResponseis the only place. Let me check prod-server.ts around line 572 to see if it does any header post-processing that might strip Cache-Control.Assistant
Let me check how the prod server dispatches the pages response and whether it strips/overrides headers.
Assistant
Let me check whether the actual Next.js test suite is available in node_modules.
Assistant
Let me check the nextjs-compat TRACKING.md and any references to gssp Cache-Control behavior.
Assistant
Let me look at the cloudflare-pages-router ssr.spec.ts to understand the structure of gssp tests in the e2e suite.
Assistant
Let me check the cloudflare worker deploy handler to see if there's a different response path.
Assistant
Let me look at the deploy.ts and find the worker runtime request handler.
Assistant
Let me look at how the renderPage response is returned in the worker, and whether it manipulates headers.
Assistant
Let me search the fixtures for any gssp pages that set Cache-Control.
Assistant
Let me look at the pages-data-route.test.ts and pages-page-data.test.ts to understand the data path tests.
Assistant
Let me search the tests for how the data path headers are tested.
Assistant
Let me look at the pages-page-data.test.ts to understand the data path test for resolvePagesPageData, particularly the isDataReq case and header forwarding.
Assistant
Now let me implement the fix. First, the HTML path in pages-page-response.ts. Let me view the exact lines.
Assistant
Now let me make the edits. First, update the import and the Cache-Control logic in pages-page-response.ts:
Assistant
Let me use the edit command instead. First, open the file.
Assistant
Now let me run the repro test again to confirm the default is fixed.
Assistant
Now let me fix the data path. Let me look at the imports available in the generated pages-server-entry.ts.
Assistant
Let me look at how the path variables like
_pagesPageDataPathare defined.Assistant
Let me view the exact data path code.
Assistant
Let me add the
_cacheControlPathconstant.Assistant
Now add the import line in the generated template. Let me add it after the renderPagesPageResponse import.
Assistant
Let me use sed for this import addition since the replace command needs the line visible.
Assistant
Now let me fix the data path. Let me navigate to it.
Assistant
Let me reconsider the gating. I need to distinguish gssp from getStaticProps static pages. Let me check the isr spec for data request Cache-Control expectations.
Assistant
Let me search for tests that check data request Cache-Control for getStaticProps.
Assistant
Let me gate the HTML path default on
gsspResto avoid changing getStaticProps static page behavior. Let me update.Assistant
Now let me update the data path to gate the default on
gsspResto keep getStaticProps data requests unchanged.Assistant
Let me remove the now-unused
__buildRevalidateCacheControlimport.Assistant
Now let me run the relevant existing unit tests to make sure I didn't break anything.
Assistant
All pass. Now let me verify the generated entry template is valid. Let me run the entry-templates test and build the package.
Assistant
I used backticks in comments inside a template literal, which breaks it. Let me check how the file escapes backticks elsewhere.
Assistant
Backticks must be escaped as ```. Let me fix my added comments.
Assistant
Let me replace the comment lines with escaped backticks.
Assistant
Let me check the entry-templates test to see if it asserts imports.
Assistant
Now let me build the vinext package to ensure TypeScript compiles correctly.
Assistant
TypeScript compiles. Let me run a broader set of tests to make sure I didn't break anything.
Assistant
All pass. Let me do an end-to-end verification by building the pages-basic fixture and curling the /ssr page. First, let me build vinext and the fixture.
Assistant
Let me build vinext and the fixture, then test the /ssr page response.
Assistant
The build is too slow/timed out. Let me check if dist already exists from the tsc I ran. Let me check the dist directory and whether the CLI is available.
Assistant
The pages-router integration tests already exercise the full renderPage path. Let me check if any existing test asserts gssp Cache-Control, and add a temporary end-to-end check via the integration test harness instead of a slow build.
Assistant
Let me look at the existing gssp tests in pages-router.test.ts around lines 395-460 and 1395-1420.
Assistant
These tests use a fixture dev server from the updated src. Let me look at the test setup and the fixture-dev-server helper.
Assistant
Let me find the dev server fixture setup for the main test group (where baseUrl and the /ssr pages are defined).
Assistant
Let me look at the helpers.js to understand startFixtureServer and buildId access.
Assistant
Let me look at how the data path test gets BUILD_ID.
Assistant
Let me create a temporary end-to-end test to confirm Cache-Control for both HTML and data paths.
Assistant
Interesting — the custom override works in dev but the default doesn't. Let me check the dev-server.ts which may use a different rendering path.
Assistant
The dev server uses a separate rendering path. Let me examine the dev-server.ts gssp handling and data path.
Assistant
Let me see the rest of the dev server's response building and the data path.
Assistant
Let me see the dev server's HTML streaming and header handling (around line 1000-1080).
Assistant
Now I understand — the dev server has its own gssp header logic lacking the default. Let me fix the dev server too for consistency. Let me check the dev-server imports.
Assistant
Let me add the
NEVER_CACHE_CONTROLimport to dev-server.ts.Assistant
Now let me add a
gsspRanflag. Let me view the exact declaration.Assistant
Now let me set
gsspRan = trueafter the gSSP short-circuit guard.Assistant
Now let me update the dev server's data path to set the default Cache-Control for gssp. Let me view the data path.
Assistant
Now let me update the dev HTML header logic. Let me find the extraHeaders block.
Assistant
Now let me run the e2e test again to confirm the dev server fix.
Assistant
All 4 dev e2e tests pass. Now let me verify the prod path. Let me run the full pages-router integration tests (which include prod build tests) plus the related unit tests.
Assistant
Let me check the helpers for building and starting a prod server to verify the prod path end-to-end.
Assistant
Let me look at how the prod test starts the built server after buildPagesFixture.
Assistant
Let me look at the full prod test setup to model a temporary prod verification.
Assistant
Let me write a temporary prod-mode test to verify the prod path (both HTML and data) emits the correct Cache-Control.
Assistant
All prod tests pass. Now let me run a broader set of potentially-affected tests to ensure no regressions.
Assistant
All pass. Let me run the TypeScript check and lint on the changed files to be sure.
Assistant
Lint passes. Now let me clean up the temporary test files.
Assistant
Now let me run a final broad set of the most relevant tests to confirm no regressions.
Assistant
Let me also run the nextjs-compat tests that involve Cache-Control behavior.
Assistant
All pass. Let me review the final diff.
Assistant
Let me double-check there's no test asserting the data path doesn't forward gssp headers, and verify the ssr-headers data path behavior.
Assistant
Let me run a few more tests that exercise the dev server and request pipeline to be thorough.
Assistant
Let me refine the comment in the prod data path to be accurate about getStaticProps data requests.
Assistant
I made a heredoc error — a literal
>>> REPLACEgot inserted. Let me check and fix.Assistant
I need to remove the stray
>>> REPLACEline.Assistant
Let me re-run the entry-templates test and tsc to confirm the file is valid after the edit.
Assistant
Let me re-run a quick verification with a temporary prod + dev e2e test to confirm everything still works end-to-end.
Assistant
All 5 verification tests pass. Let me clean up the temp file and do a final lint check.
Assistant
Let me do a final review of the complete diff.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.