Skip to content
TheChatArchiveThe Chat Archive
composer-2.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

    I'll trace how Pages Router gSSP responses are built and where Cache-Control should be applied.

  3. Assistant

    Implementing the fix: default gSSP Cache-Control in the response builder, dev server, and _next/data path.

  4. Assistant

    Adding the fixture page and tests.

  5. Assistant

    Fixed missing Cache-Control headers on Pages Router getServerSideProps responses.

    Root cause

    gSSP responses only set Cache-Control for ISR pages (isrRevalidateSeconds) or nonce-bearing pages. Plain gSSP pages skipped it entirely, and user overrides via res.setHeader('Cache-Control', ...) were dropped on the /_next/data path because the generated entry read gsspRes.headers instead of gsspRes.getHeaders().

    Changes

    1. pages-page-response.ts — After applying gSSP headers, emit the Next.js default NEVER_CACHE_CONTROL when no Cache-Control is already set.

    2. dev-server.ts — Same default for HTML and /_next/data responses in dev.

    3. pages-server-entry.ts — Fix /_next/data header forwarding to use getHeaders(), and apply the default Cache-Control for gSSP when the user did not override it.

    4. Tests

      • Unit tests in pages-page-response.test.ts
      • Integration tests in pages-router.test.ts (dev + prod)
      • Fixture page ssr-cache-control.tsx for override behavior

    Verification

    pnpm test tests/pages-page-response.test.ts
    pnpm test tests/pages-router.test.ts -t "Cache-Control"
    pnpm test tests/pages-router.test.ts -t "serves pages from production build end-to-end"
    

    All passed.

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