Skip to content
TheChatArchiveThe Chat Archive
fable-5· unknownHugging Face ibragim-bad/swe_rebench_07_2026_trajectories

Pages Router: gssp/getStaticProps responses missing default and user-set Cache-Control…

  1. User

    Pages Router: gssp/getStaticProps responses missing default and user-set Cache-Control header

    This issue was created by an agent analysing CI failures from the Next.js Deploy Suite (vinext main vs Next.js v16.2.6, 2026-05-22).

    Problem

    Pages Router gssp responses lack Cache-Control headers. Tests expect the default private, no-cache, no-store, max-age=0, must-revalidate for gssp pages and custom values set via res.setHeader('Cache-Control', ...), but vinext returns null. The default header is not applied and user setHeader calls are dropped.

    Expected: "private, no-cache, no-store, max-age=0, must-revalidate"
    Received: null
    

    Estimated Impact

    ~2 test failures across the deploy suite.

    Affected Test Suites

    • test/e2e/getserversideprops/test/index.test.ts (2 failures)

    Recommendation

    1. Reproduce first in vinext's own test suite. Add a Pages Router gssp page and assert the response carries the default Cache-Control header; add a second page that overrides it via res.setHeader and assert the override sticks.

    2. 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-revalidate unless the user set it explicitly.

    3. Preserve res.setHeader overrides. Make sure headers set during gssp dispatch are forwarded to the final HTTP response.

    Interface

    No new interfaces are introduced.

  2. Assistant

    Let me write a quick repro against the built pages entry:

  3. Assistant

    Now I understand the structure. Let me check for any existing tests asserting absent Cache-Control that my change could break:

  4. Assistant

    Now the _next/data JSON path in the pages server entry. Let me look at how that entry template imports helpers:

  5. Assistant

    Now fix the _next/data branch in the entry template. First add the cache-control import:

  6. Assistant

    Now update buildNextDataJsonResponse to handle Headers instances (the current object-spread would silently drop them):

  7. Assistant

    Now add a fixture page that overrides Cache-Control:

  8. Assistant

    Now add unit tests to tests/pages-page-response.test.ts:

  9. Assistant

    Now add integration tests to the production server suite:

  10. Assistant

    Now run the surrounding test files to check for regressions:

  11. Assistant

    While that runs, check the dev-server _next/data path for the same dropped-headers bug:

  12. Assistant

    All 245 pages-router tests pass. Run the broader pages/deploy-related suites:

  13. Assistant

    Resource contention with the background run — I'll retry checks after tests finish.

  14. Assistant

    All 459 pass. Now retry the repo check (lint + typecheck + format):

  15. Assistant

    The diff is clean. Waiting on the prerender suite results:

  16. Assistant

    All green. Summary of the fix:

    Root causes

    1. Missing default header (the 2 deploy-suite failures): renderPagesPageResponse (packages/vinext/src/server/pages-page-response.ts) only set Cache-Control for CSP-nonce responses and ISR pages. Plain gSSP pages got no header at all.
    2. Dropped res.setHeader values on _next/data requests: the generated pages entry read gsspRes.headers, which doesn't exist — the node-compat res only exposes getHeaders() — so all gSSP headers/cookies were silently dropped from data responses (a latent bug from #1412).

    Changes

    • packages/vinext/src/server/pages-page-response.ts — after applyGsspHeaders copies user headers into the response, gSSP pages now default to private, no-cache, no-store, max-age=0, must-revalidate (NEVER_CACHE_CONTROL) unless the user already set Cache-Control. Mirrors Next.js sendRenderResult with gSSP's cacheControl: { revalidate: 0 }. User overrides win; nonce/ISR branches are untouched.
    • packages/vinext/src/entries/pages-server-entry.ts — the _next/data branch now reads gsspRes.getHeaders(), forwards multi-value Set-Cookie via Headers.append, and applies the same never-cache default when the user didn't set one.
    • packages/vinext/src/server/pages-data-route.ts — buildNextDataJsonResponse builds headers via the Headers constructor (object spread would drop a passed-in Headers instance) and forces Content-Type: application/json for the data endpoint.
    • tests/fixtures/pages-basic/pages/ssr-custom-cache.tsx — new fixture mirroring Next.js' custom-cache page (res.setHeader("Cache-Control", "public, max-age=3600")).

    Tests (reproduced failing, now passing)

    • Unit (tests/pages-page-response.test.ts): default applied for gSSP, user override preserved, no default for non-gSSP pages.
    • Integration (tests/pages-router.test.ts, full prod-server path): default + override on HTML responses, default + override on _next/data responses, and gSSP header/cookie forwarding to data responses.

    Verification

    • tests/pages-router.test.ts: 245 passed; pages-page-response: 12 passed
    • Related suites (pages-data-route, pages-data-url, pages-page-data, entry-templates, cache-control, pages-i18n, pages-i18n-prod, features, pages-router-concurrency, request-pipeline, prerender, prod-server-prerender-seeder): 625 passed, 0 failed
    • pnpm check (format + lint + typecheck): clean

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.