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 and searching for relevant Cache-Control / gssp handling code.
- Assistant
Let me look at the project docs and search for Cache-Control / gssp handling.
- Assistant
rg is not found, let me use grep instead.
- Assistant
Reading the cache-control and pages response handling source files.
- Assistant
Inspecting gssp data handling and related tests.
- Assistant
Checking how gssp req/res is created and how deploy mode handles cache headers.
- Assistant
Let me read pages-node-compat.ts fully and the relevant sections of pages-page-data.ts and pages-page-response.ts, as well as prod-server for how gssp is handled. Also check deploy-related tests.
- Assistant
Checking data-route and prod paths for gssp header handling, and related tests.
- Assistant
Looking at deploy handling and where pages responses get finalized for cloudflare.
- Assistant
Hmm, nothing in cloudflare. Let me look at prod-server more carefully for pages rendering.
- Assistant
Very few matches. Maybe prod-server uses a shared request pipeline. Let me check request-pipeline.ts.
- Assistant
Odd - request-pipeline has no matches. Let me look at how interval pages responses are wired - maybe through a virtual module or entries.
- Assistant
Let me read the pages-server-entry.ts around the data response and render path.
- Assistant
Let me continue reading.
- Assistant
Found a bug in data-req header forwarding. Checking HTML path finalization and Next.js expected defaults.
- Assistant
Let me look at pages-page-response.test.ts and how app path sets default cache header for dynamic pages. Also check getStaticProps without revalidate - getStaticProps without revalidate is static and ...
- Assistant
Checking existing tests for gssp headers and Next.js reference comments.
- Assistant
Checking git history and Next.js deploy suite references for this Cache-Control issue.
- Assistant
Looking at the related fix for revalidate=0 and how Headers get stripped in the worker/prod path.
- Assistant
Let me look at
sendWebResponseandstripHeaders- they might be stripping Cache-Control. - Assistant
Looking at the fixture for ssr-headers and any worker/deploy path issues.
- Assistant
Looking at how route handlers preserve custom Cache-Control as a pattern to follow.
- Assistant
Let me also look at getStaticProps default. The issue says "gssp / getStaticProps". For getStaticProps without revalidate, when rendered on demand in deploy... Actually getStaticProps pages are typica...I understand the issue you're describing. The problem is that in Next.js Pages Router, getServerSideProps (gSSP) responses are missing the default
Cache-Controlheader (private, no-cache, no-store, max-age=0, must-revalidate) and user-set headers viares.setHeaderare being dropped. This matches the expected behavior in Next.js, where gSSP pages should always have that default unless overridden.To address this, I need to:
-
Reproduce the issue: I'll add a test page for gSSP and assert the default header, plus one that overrides it.
-
Emit the default header: In the response handling for gSSP pages, ensure the default
Cache-Controlis set unless the user has explicitly set it. -
Preserve overrides: Make sure
res.setHeadercalls are respected.
I'll start by exploring the codebase to find where response headers are handled, especially for gSSP pages.
-
- Assistant
Checking if Next.js source is available for reference on default gssp Cache-Control.
- Assistant
Let me look at Next.js base-server and pages route for when Cache-Control is set.
- Assistant
Confirming Next.js only sets default Cache-Control if the user hasn't set it. Checking render.js and send-payload fully.
- Assistant
Looking at render.js lines 647 and 719:
- Assistant
Checking deployed worker path for pages gssp handling.
- Assistant
I have a clear plan. Implementing default gSSP Cache-Control and fixing data-request header forwarding.
- Assistant
Updating pages-page-response.ts to apply the default gSSP Cache-Control.
- Assistant
Now update the Cache-Control setting logic at the end of renderPagesPageResponse.
- Assistant
Updating the Cache-Control application logic.
- Assistant
Fixing the comment typo, then updating the data-request path.
- Assistant
Fixing the data-request path in pages-server-entry (template string).
- Assistant
Adding a shared helper for gSSP headers so the data req path can reuse it.
- Assistant
Need to goto the line first.
- Assistant
Now I can edit.
- Assistant
Fixing a typo in the comment.
- Assistant
Updating renderPagesPageResponse to use applyDefaultGsspCacheControl for consistency.
- Assistant
Need to goto line 417.
- Assistant
Now replace.
- Assistant
Updating pages-server-entry for the data-request path.
- Assistant
Updating the import and isDataReq block.
- Assistant
Now fix the isDataReq block.
- Assistant
buildNextDataJsonResponse accepts headers as a Record. I need to convert Headers to a plain object, or change buildNextDataJsonResponse to accept Headers. I need to fix the gssp Cache-Control header issue in Next.js Pages Router. The problem is that
buildNextDataJsonResponsedoesn't properly handle Headers objects, and we're losing the defaultCache-Controlheader and any user-set headers.Let me think about the best approach:
- Assistant
Updating
buildNextDataJsonResponseto properly handle Headers objects. - Assistant
I'll update buildNextDataJsonResponse to properly merge Headers.
- Assistant
Updating the dev-server for default Cache-Control parity on gSSP.
- Assistant
Let me see the gssp extra headers collection and where Cache-Control is applied.
- Assistant
Let me look at extraHeaders section again around 1040-1080 and data req section.
- Assistant
For dev-server, I'll add default9 Cache-Control for gSSP and data paths.
- Assistant
Now fix data req path in dev-server.
- Assistant
In data path of math, gsspEXTRA headers are already her. Add default cache control.
- Assistant
Also applying default Cache-Control when gSSP short-circuits via res.end().
- Assistant
Running unit tests for pages-page-response and creating a temporary verification script.
- Assistant
The test timed out. Checking how tests are run.
- Assistant
Maybe need to build first or use vite-plus directly. Trying the unit project with a longer timeout.
- Assistant
vp test seems hung. Trying vitest directly.
- Assistant
Vitest is hanging. Writing a temporary verification script instead.
- Assistant
Rebuilding the package and verifying with a temporary script.
- Assistant
Build is also timing out. Checking whether pnpm itself is hanging.
- Assistant
Corepack was prompting for download confirmation. Using local binaries instead.
- Assistant
Existing tests pass. Writing a temporary script to verify Cache-Control behavior.
- Assistant
Using the system tsx binary.
- Assistant
Running from the repo root so node_modules resolve.
- Assistant
Putting the script in the repo so modules resolve correctly.
- Assistant
All checks passed. Running related unit tests and cleaning up.
- Assistant
Verifying the full diff before submitting.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.