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
I'll start by exploring the repository structure to understand the codebase.
Assistant
Let me look at the related files for cache control and gssp dispatch.
Assistant
I need to make single tool calls. Let me look at the related files.
Assistant
There's a
NEVER_CACHE_CONTROLconstant that matches the expected valueprivate, no-cache, no-store, max-age=0, must-revalidate. Now let me find whererenderPagesPageResponseis called and howgsspResis created.Assistant
Now let me look at the
pages-page-data.tsfile to understand how the gsspRes is created and how headers/status are tracked.Assistant
Now let me look at the
renderPagesPageResponsefunction more closely to understand the cache control logic. Let me look at the relevant part again:Assistant
Now I understand the structure. Let me look at how
createGsspReqResis implemented to understand the gsspRes headers.Assistant
Let me look at the test suite mentioned in the issue and how the deploy mode works.
Assistant
Let me look for the Next.js reference test for getserversideprops.
Assistant
Let me look at the existing tests for pages-page-response and cache-control to understand the testing patterns and expectations.
Assistant
Now I understand the existing tests. Let me look at the cache-control test to understand the expected default behavior for gssp.
Now let me understand the issue. The test that's failing is
test/e2e/getserversideprops/test/index.test.tsfrom the Next.js deploy suite. Let me look at the actual Next.js test to understand what it expects.The Next.js
getserversidepropstest typically checks:- A gssp page returns
Cache-Control: private, no-cache, no-store, max-age=0, must-revalidate - A gssp page that sets a custom Cache-Control via
res.setHeaderkeeps the override.
Let me look at the Next.js test file. Let me search the repo for any reference.
Let me check the deploy test to understand how vinext runs these tests.
- A gssp page returns
Assistant
Let me look at the vinext cache-control test and the pages-page-data test to understand expectations.
Assistant
Now let me understand the actual behavior by writing a reproduction test. Let me create a temporary test script.
Assistant
Let me check how tests are run in this repo.
Assistant
The reproduction confirms the default Cache-Control is
nullfor gssp pages. The custom case passes in the HTML path. Let me check the data request path which usesgsspRes.headers(likely undefined). Let me look atbuildNextDataJsonResponse.Assistant
Let me search for related tests in the vinext test suite to understand the expected behavior.
Assistant
Let me look at the data request test for gssp in vinext's test suite.
Assistant
Let me look at the actual Next.js getserversideprops test to understand the exact assertions. Let me search the repo for any reference and check the pages-basic fixtures.
Assistant
Let me check the actual Next.js getserversideprops test and app pages. Let me search the filesystem.
Assistant
Let me check if Next.js source is available in node_modules to find the actual test.
Assistant
The e2e tests aren't shipped. Let me look at how Next.js applies the cache-control header for gssp in the installed package.
Assistant
Let me look at how Next.js sets the cache-control header for gssp (SSP) responses in pages-handler.js.
Assistant
Now I understand Next.js's behavior. For gssp (no static props), it sets
Cache-Control: private, no-cache, no-store, max-age=0, must-revalidateby default, but only if the user hasn't already set it viares.setHeader. Let me look at the actual Next.js getserversideprops e2e test and app pages. Let me check the agents/opencode directories for deploy suite notes.Assistant
Let me look at the GitHub Actions workflow to understand the deploy suite and find the actual Next.js test.
Assistant
Let me try to fetch the actual Next.js getserversideprops test from GitHub to understand the exact assertions.
Assistant
I have network access. Let me examine the test.
Assistant
Now I have the exact tests. Let me look at the
/somethingand/custom-cachepages in the Next.js test app.Assistant
Now I have full clarity on the issue. Let me look at what
scriptNoncerepresents in vinext to understand the nonce branch.Assistant
Let me check the existing tests for data request cache-control, especially for getStaticProps.
Assistant
Let me look at the cache-headers.ts helper.
Assistant
Now I have full clarity on the issue. Let me look at the data request path in detail in the pages-server-entry template.
Assistant
Let me look at the imports and structure of the pages-server-entry template.
Assistant
Let me check existing expectations for static (getStaticProps without revalidate) page cache-control.
Assistant
Let me look at the top of the pages-server-entry template to understand how paths and imports are set up.
Assistant
Let me look at how the template builds the import block and the full generated structure.
Assistant
Let me check if any test asserts that getStaticProps data requests have no cache-control (to avoid breaking behavior).
Assistant
Let me check the existing pages-router test for any getStaticProps data request cache-control assertions and how the prod server tests work.
Assistant
I now have a complete understanding. The 2 failing tests are:
should set default caching header—/something(gssp) HTML + data → expectsprivate, no-cache, no-store, max-age=0, must-revalidateshould respect custom caching header—/custom-cache(gssp, setsres.setHeader('Cache-Control', 'public, max-age=3600')) HTML + data → expectspublic, max-age=3600
Two issues:
- HTML path: default gssp
Cache-Controlis never emitted. - Data path:
gsspRes.headersisundefined(should begetHeaders()), so user-set headers AND status are dropped, and no default is set.
Let me implement the fixes. First, the HTML path in
pages-page-response.ts:Assistant
Now let me make the HTML path fix. First, update the import:
Assistant
Now let me add the gssp default Cache-Control branch:
Assistant
The replace command needs the file to be scrolled to the right location. Let me use
gotofirst or useeditwith line numbers.Assistant
Now let me fix the data path. First, I'll add a helper to
pages-data-route.tsthat forwards gssp headers/status and applies the default Cache-Control:Assistant
Now let me add the import and a new helper function. First, add the import at the top:
Assistant
Now let me add the new helper after
buildNextDataJsonResponse:Assistant
Now let me update the template to import and use the new helper. First, update the import line:
Assistant
Now let me update the data path logic in the template:
Assistant
Now let me check the dev-server.ts which might have a separate data path that needs the same fix.
Assistant
Let me look at the dev server's data request and cache-control handling.
Assistant
Let me look at the dev server's HTML cache-control handling around line 1050.
Assistant
The dev server is a separate path used only for
next dev(not deploy mode, which is what the failing tests use). Let me first verify my deploy-mode fixes. Let me update my reproduction test to cover both the HTML path and the new data helper:Assistant
All 6 reproduction tests pass. Now let me run the existing unit tests for the affected files to make sure I didn't break anything.
Assistant
All existing unit tests pass. Now let me run the integration tests for the pages router which exercise the full build + server path.
Assistant
The backticks in my comment break the template literal (the whole entry is inside a backtick string). I need to escape them. Let me fix:
Assistant
Now let me re-run the integration test:
Assistant
All 241 integration tests pass. Now let me verify end-to-end with a temporary fixture and test that mirrors the Next.js getserversideprops test. Let me look at how the integration test sets up the prod server.
Assistant
Let me look at how the prod server is started in the pages-router test.
Assistant
Let me check the pages-basic fixture's next.config for the build id and structure.
Assistant
Let me look at the prod-server build setup to write a self-contained temporary test.
Assistant
Let me look at the
renderPagefunction in the template to understand how data requests are handled.Assistant
The
renderPageauto-detects data requests. Let me create a temporary fixture page and a temporary end-to-end test mirroring the Next.js getserversideprops assertions.Assistant
The integration project has an explicit include list. Let me run under the unit project instead:
Assistant
Both end-to-end tests pass, confirming the fix works in deploy/production mode. Now let me check whether the dev server also needs handling, and whether any dev-mode test checks gssp cache-control.
Assistant
The dev server isn't part of the failing tests (the issue specifies deploy mode), and there's no dev-mode test asserting gssp cache-control, so I'll leave it unchanged. Now let me clean up the temporary files and run the broader test suite.
Assistant
Now let me run a broader set of relevant tests to ensure nothing is broken.
Assistant
Let me run the entry-templates and pages-router-concurrency integration tests, which exercise the server entry generation.
Assistant
All tests pass. Let me run a typecheck to ensure my TypeScript changes are valid.
Assistant
Typecheck passes. Let me review my final changes.
Assistant
The diff looks clean. Let me verify the getserversideprops test app doesn't use CSP nonce (which would route through the nonce branch). Let me check its config and middleware.
Assistant
The getserversideprops test app has no middleware (no CSP nonce). So the
/somethingand/custom-cachepages won't have a nonce. The nonce branch won't be hit. My gssp default branch will be hit for these pages.Let me verify there's no nonce setup in the next.config (e.g., headers setting Content-Security-Policy with nonce). Let me check the full next.config.
Assistant
The getserversideprops test app has no CSP nonce, so my gssp default branch will be hit correctly.
Now let me refine the data-route helper to avoid duplicating the
PagesGsspResponsetype — I'll import the canonical type instead, matching the existing pattern inpages-page-data.ts. First let me verify there's no circular dependency.Assistant
No circular dependency. Let me update the helper to use the canonical
PagesGsspResponsetype:Assistant
Let me add the
PagesGsspResponsetype import:Assistant
Now let me remove the duplicate
PagesDataGsspResponsetype and usePagesGsspResponseinstead:Assistant
There's a duplicate
}): Response {line. Let me fix it:Assistant
The helper now uses the canonical
PagesGsspResponsetype. Let me re-run the typecheck and tests to confirm:Assistant
Typecheck passes. The type-only import is erased at runtime, so no circular dependency. Let me re-create the temporary reproduction tests to verify the refactor still works:
Assistant
Both e2e tests pass. Let me clean up the temporary files and run the final verification of the affected test suites.
Assistant
All tests pass. Let me run the linter on the changed files to ensure no lint errors:
Assistant
Lint passes with 0 errors. Let me do a final review of the complete diff:
Assistant
The diff is clean and complete. Let me do a final check that no temporary files remain:
Assistant
Only my intended changes remain — no leftover temporary files. Let me run one final broad check on the dev-server-related and prerender tests to be safe, since the data path change could theoretically interact with prerender/static export.
Assistant
Those are in the integration project. Let me run them there:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.