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 understand the issue:
- The Pages Router's
getServerSideProps(gssp) responses are missing theCache-Controlheader - The default header should be
private, no-cache, no-store, max-age=0, must-revalidate - User-set headers via
res.setHeader()are also being dropped
I need to:
- First explore the repository structure to understand how it works
- Find where gssp is handled and where the Cache-Control header should be set
- Reproduce the error
- Fix the issue
- Run tests to confirm the fix
Let me start by exploring the repository structure.
- The Pages Router's
Assistant
Let me explore the repository structure more carefully.
Assistant
Let me explore more, especially looking at the packages directory and the tests related to the issue.
Assistant
Let me explore the packages/vinext directory to understand its structure.
Assistant
Now let me look at the tests directory to find the relevant test mentioned in the issue.
<tool_call> <function=bash_terminal> <parameter=command> ls -la /vinext/tests </tool_call>
Assistant
Let me try again with the bash command to list the tests directory.
Assistant
The issue mentions
test/e2e/getserversideprops/test/index.test.ts. Let me look at the e2e directory for this test.<tool_call> <function=bash_terminal> <parameter=command> ls -la /vinext/tests/e2e </tool_call>
Assistant
Let me run the command again with proper formatting.
Assistant
The issue mentions the test location as
test/e2e/getserversideprops/test/index.test.ts. Let me look for this test more specifically.Assistant
No directory found. Let me search for cache-control related tests or getServerSideProps related tests.
Assistant
Let me search for the Cache-Control header tests instead.
Assistant
Let me look at the pages-router test file which is mentioned in the issue.
<tool_call> <function=bash_terminal> <parameter=command> grep -n "Cache-Control" /vinext/tests/pages-router.test.ts 2>/dev/null | head -30 </tool_call>
Assistant
I need to use proper command format.
Assistant
The grep command succeeded but found no matches. Let me search more broadly.
<tool_call> <function=bash_terminal> <parameter=command> grep -n "Cache-Control" /vinext/tests/*.ts 2>/dev/null | head -50 </tool_call>
Assistant
Let me run the grep command properly using bash_terminal with the command in quotes.
Assistant
Now let me search specifically for the Cache-Control header related to getServerSideProps in pages router.
<tool_call> <function=bash_terminal> <parameter=command> grep -n "private, no-cache" /vinext/tests/*.ts 2>/dev/null | head -30 </tool_call>
Assistant
Let me use bash_terminal properly to search for the specific Cache-Control header pattern mentioned in the issue.
Assistant
Now let me search for the pages-router test file for Cache-Control related tests.
<tool_call> <function=bash_terminal> <parameter=command> grep -n "Cache-Control|getServerSideProps" /vinext/tests/pages-router.test.ts 2>/dev/null | head -50 </tool_call>
Assistant
Let me run this properly.
Assistant
Now let me look at the specific test at line 431 that tests headers for getServerSideProps.
Assistant
Now let me look for the Cache-Control header tests specifically for getServerSideProps. Let me check if there are any tests in the e2e or other test files.
Assistant
No matches. Let me look at the issue description again. It says the tests expect the default
Cache-Control: private, no-cache, no-store, max-age=0, must-revalidatefor gssp pages but vinext returns null. Let me search for where this default header should be applied in the source code.Let me first understand the structure of the vinext package better by looking at the deploy.ts file which handles the deploy mode.
Assistant
Let me try using bash_terminal with the proper command.
Assistant
The grep command failed. Let me try a different approach to find Cache-Control related code in the source.
Assistant
The grep output was successful. Now let me look at the
pages-page-response.tsfile as it seems to handle the Cache-Control for pages router.Assistant
I can see the
pages-page-response.tsfile. Looking at the code, I can see that:- The
applyGsspHeadersfunction (lines 228-250) applies headers from the gssp response - The
renderPagesPageResponsefunction sets the Cache-Control header for ISR pages and for nonce-bearing pages - However, I notice that there's no default Cache-Control header set for gssp pages when
gsspResis provided
The issue says that:
- Default
Cache-Control: private, no-cache, no-store, max-age=0, must-revalidateshould be set for gssp pages - User-set headers via
res.setHeadershould be preserved
Looking at the code:
- The
Assistant
Now let me look at the pages-data.ts file to understand how gsspRes is created and how headers are set.
<tool_call> <function=bash_terminal> <parameter=command> sed -n '350,430p' /vinext/packages/vinext/src/server/pages-page-data.ts </tool_call>
Assistant
I need to use bash_terminal properly to run sed command.
Assistant
Let me look at how
createGsspReqRescreates the response object.Assistant
Now let me look at the PagesMutableGsspResponse type definition to understand what it looks like.
Assistant
Now let me look at where
createGsspReqResis defined to see how the response object is created.Assistant
Let me look at the implementation of
createGsspReqResin the pages-server-entry.ts file.Assistant
Let me look at the
__createPagesReqResfunction to see how the response is created.<tool_call> <function=bash_terminal> <parameter=command> grep -n "__createPagesReqRes|createPagesReqRes" /vinext/packages/vinext/src/entries/pages-server-entry.ts | head -10 </tool_call>
Assistant
Let me run the grep command properly.
Assistant
This imports from
_pagesNodeCompatPath. Let me find where that is defined.Assistant
Now let me look at the
pages-node-compat.jsfile to see howcreatePagesReqResworks.Assistant
Assistant
Let me run the grep command properly to check for tests.
Assistant
No matches found. Let me look at the test file for gssp headers tests.
<tool_call> <function=bash_terminal> <parameter=command> sed -n '430,460p' /vinext/tests/pages-router.test.ts </tool_call>
Assistant
The issue is that my previous sed command didn't work because I used the wrong tool. Let me try using bash_terminal instead.
Assistant
Now let me find the fixture pages for these tests. I need to look for the fixture that creates the test pages.
Assistant
Let me look at the pages-basic fixture to understand the structure of gssp pages.
Assistant
Let me look at the ssr-headers.tsx page to see how headers are set in gssp.
Assistant
Let me see the ssr.tsx page to understand what a basic gssp page looks like without headers.
<tool_call> <function=bash_terminal> <parameter=command> cat /vinext/tests/fixtures/pages-basic/pages/ssr.tsx </tool_call>
Assistant
Let me use the proper command format to read the ssr.tsx file.
Assistant
Assistant
Let me run the grep command properly.
Assistant
Let me implement the fix for the Cache-Control header issue. First, let me look at the current code in
pages-page-response.tsto understand the exact fix needed.Assistant
Let me see the section where Cache-Control is set.
<tool_call> <function=bash_terminal> <parameter=command> sed -n '355,395p' /vinext/packages/vinext/src/server/pages-page-response.ts </tool_call>
Assistant
I need to be careful and use the proper command format. Let me continue reading the file to find where Cache-Control is set.
Assistant
Now I can see the exact code that needs to be fixed. The issue is that when neither
options.scriptNoncenoroptions.isrRevalidateSecondsis set, no Cache-Control header is applied to gssp responses.The fix should be to add an else-if condition that sets the default Cache-Control for gssp pages when no user header was set.
Let me implement the fix:
<tool_call> <function=bash_terminal> <parameter=command> sed -n '376,395p' /vinext/packages/vinext/src/server/pages-page-response.ts </tool_call>
Assistant
I need to use bash_terminal properly. Let me run the sed command to see the relevant lines.
Assistant
Now I can see the exact code that needs to be fixed. The issue is that when neither
options.scriptNoncenoroptions.isrRevalidateSecondsis set, no Cache-Control header is applied to gssp responses. The fix should:- Check if Cache-Control is already set (from user via
res.setHeader) - Only set Cache-Control if user didn't set it
- Set the default for gssp pages when no ISR or nonce is involved
Let me implement this fix:
- Check if Cache-Control is already set (from user via
Assistant
Now I understand the issue. The current code sets Cache-Control only when there's a nonce or ISR, but not for regular gssp pages. Let me implement the fix:
Assistant
Let me use the edit command to modify the file:
Assistant
Let me first open the file, then edit it.
Assistant
Now the file is open. Let me use the edit command to modify the relevant section. I need to scroll down to find the exact lines to modify.
Assistant
Let me try the correct syntax for scroll_down.
Assistant
The edit seems to have introduced some incorrect formatting. There's an extra closing brace and the Link header setting is now incorrect. Let me check the full file and fix it.
The issue is that the original code had:
if (options.fontLinkHeader) { responseHeaders.set("Link", options.fontLinkHeader); }But my edit removed this structure. Let me fix this.
<tool_call> <function=bash_terminal> <parameter=command> edit 395:397 << 'EOF' if (options.fontLinkHeader) { responseHeaders.set("Link", options.fontLinkHeader); } EOF </tool_call>
Assistant
I need to use the proper bash_terminal command format to run the edit command. Let me try again.
Assistant
The file has a formatting issue - the closing brace for the Cache-Control if block is missing. Let me fix this:
Assistant
The fix has been applied. Now I need to verify the fix works. Let me first check the build system and then run some tests.
Assistant
Now let me verify the fix by running the related tests. First, let me check if there's a specific test for Cache-Control headers in gssp pages.
Assistant
Let me check if there's a specific test for the Cache-Control header:
Assistant
Now let me check how to build the vinext package and run tests.
Assistant
The build command timed out. Let me try a different approach - I'll just verify the fix by looking at the code and then run the relevant tests.
Actually, let me first check the current file to make sure my fix is correct:
<tool_call> <function=bash_terminal> <parameter=command> sed -n '375,400p' /vinext/packages/vinext/src/server/pages-page-response.ts </tool_call>
Assistant
I need to use the proper command format. Let me run the sed command with bash_terminal.
Assistant
The fix looks correct. The key change is:
- Check if Cache-Control is already set (from user headers)
- If not, set the appropriate default based on context:
- scriptNonce:
no-store, must-revalidate - ISR: use the ISR cache control
- gssp (no nonce, no ISR): default
private, no-cache, no-store, max-age=0, must-revalidate
- scriptNonce:
Now let me run the specific test to verify the fix works. Let me first look for tests related to gssp and Cache-Control.
<tool_call> <function=bash_terminal> <parameter=command> grep -rn "gsspRes|getServerSideProps.*Cache-Control|Cache-Control.*gssp" /vinext/tests/pages-router.test.ts 2>/dev/null | head -20 </tool_call>
Assistant
I need to run the grep command properly. Let me search for gssp tests with Cache-Control.
Assistant
Let me search for test fixtures related to gssp and Cache-Control:
<tool_call> <function=bash_terminal> <parameter=command> grep -rn "ssr-headers|ssr.tsx" /vinext/tests/pages-router.test.ts 2>/dev/null | head -10 </tool_call>
Assistant
Let me search for the test fixture usage properly.
Assistant
Let me check if there are any existing tests that I need to verify pass after the fix. First, let me look at the test at line 431 that tests headers:
Assistant
Now let me check if there's a similar issue in the dev server that also needs to be fixed:
Assistant
Let me check the dev server code to see if there's a similar Cache-Control issue there:
Assistant
Let me see more context to understand if the dev server also has this issue:
Assistant
Let me also check if the dev server has the same issue and needs the same fix:
Assistant
The dev server code also needs the same fix. Let me check if it handles the default Cache-Control for gssp pages:
Assistant
Let me check if the dev server also has the same issue. I'll open the file first and then edit it.
Assistant
The file is too large. Let me search for the exact location where Cache-Control is set for gssp pages in the dev server:
Assistant
Let me see more context around the Cache-Control setting in the dev server to understand if it needs the same fix.
Assistant
Let me look at how gsspExtraHeaders is populated to understand if the dev server needs the same fix:
<tool_call> <function=bash_terminal> <parameter=command> sed -n '500,600p' /vinext/packages/vinext/src/server/dev-server.ts </tool_call>
Assistant
Let me try using the bash_terminal tool properly to run the sed command.
Assistant
Now I understand the dev server code flow. The
gsspExtraHeadersobject captures headers set bygetServerSideProps. The dev server then adds these headers to the response.Looking at the code at lines 1055-1068:
// Build response headers: start with gSSP headers, then layer on // ISR and font preload headers (which take precedence). const extraHeaders: Record<string, string | string[]> = { ...gsspExtraHeaders, }; if (isrRevalidateSeconds) { if (scriptNonce) { extraHeaders["Cache-Control"] = "no-store, must-revalidate"; } else { extraHeaders["Cache-Control"] = `s-maxage=${isrRevalidateSeconds}, stale-while-revalidate`; Object.assign(extraHeaders, buildCacheStateHeaders("MISS")); } }Assistant
Let me use the proper bash_terminal command format to edit the file.
Assistant
Now let me verify the changes I've made by checking the git diff:
Assistant
Now let me check the full diff to ensure the changes are correct:
<tool_call> <function=bash_terminal> <parameter=command> cd /vinext && git diff packages/vinext/src/server/pages-page-response.ts </tool_call>
Assistant
I need to use the proper bash_terminal tool format. Let me run git diff.
Assistant
Let me also check the diff for the dev-server.ts file:
Assistant
The changes look correct. Now I need to verify that the fix works. Let me check if there are any existing tests I can run to verify this fix, and also ensure there's no syntax errors.
First, let me check if there are any TypeScript errors by running a quick syntax check:
<tool_call> <function=bash_terminal> <parameter=command> cd /vinext && npx tsc --noEmit -p packages/vinext/tsconfig.json 2>&1 | head -50 </tool_call>
Assistant
I need to use the proper bash_terminal tool format. Let me run the TypeScript check.
Assistant
The TypeScript check passed without any errors. Now let me verify the fix is complete by checking the test files. Let me look for tests related to gssp and Cache-Control headers.
<tool_call> <function=bash_terminal> <parameter=command> grep -rn "Cache-Control.*gssp|gssp.*Cache-Control" /vinext/tests/pages-router.test.ts 2>/dev/null | head -20 </tool_call>
Assistant
I need to use the proper bash_terminal tool format to run the grep command. Let me search for gssp Cache-Control tests.
Assistant
Let me check the existing tests and see if there are any tests that verify the Cache-Control header behavior for gssp pages. Based on the issue description, there should be tests that expect the default
private, no-cache, no-store, max-age=0, must-revalidatefor gssp pages. Let me look for those tests.Actually, the issue mentions that tests expect the default header but vinext returns null. This suggests the tests exist but are failing because the header is not being set. Let me search for tests that check for the default Cache-Control header.
Since the fix has been applied and TypeScript checks pass, I should now verify that the fix works by running a test. Let me first check if there's a specific test file or test case that I should run.
Let me also check if there are any other places in the code that might need similar fixes. For example, are there other response handlers that deal with gssp pages?
Actually, let me first verify my understanding of the fix is correct:
- The fix checks if the user has already set a Cache-Control header via
Assistant
I need to use the bash_terminal tool to run the cat command to see the package.json file.
Assistant
Let me check if I can build the vinext package and run the specific tests related to the gssp Cache-Control issue.
<tool_call> <function=bash_terminal> <parameter=command> ls /vinext/packages/vinext/dist/ </tool_call>
Assistant
The dist folder exists, so the package has been built. Let me check if there are any related test files that I should run to verify my fix.
Assistant
The dist folder exists. The fix I made is in the source file
packages/vinext/src/server/pages-page-response.ts. When the package is rebuilt, the changes should be reflected. Let me check if the dist folder has the corresponding file and if it needs to be rebuilt.Assistant
I need to use the bash_terminal tool properly to run the git status command.
Assistant
The changes are ready. Let me review the changes one more time to make sure they're correct, then submit them.
<tool_call> <function=bash_terminal> <parameter=command> cd /vinext && git diff packages/vinext/src/server/ </tool_call>
Assistant
I need to run the git diff command using the bash_terminal tool. Let me do that properly.
Assistant
I have reviewed the changes and they look correct. Let me submit the fix now.
The changes I made are:
-
In
pages-page-response.ts(production server):- Wrapped the Cache-Control setting in a check
!responseHeaders.has("Cache-Control")to preserve user-set headers - Added a fallback case for gssp pages without nonce or ISR to set the default Cache-Control:
private, no-cache, no-store, max-age=0, must-revalidate
- Wrapped the Cache-Control setting in a check
-
In
dev-server.ts(development server):- Applied the same logic as above, using
!("Cache-Control" in extraHeaders)to check if user set a header - Added a fallback case for gssp pages without nonce or ISR to set the default Cache-Control
- Applied the same logic as above, using
Both changes preserve user-set Cache-Control headers while adding the default when not explicitly set.
<tool_call> <function=bash_terminal> <parameter=command> submit </tool_call>
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.