Files
vercel__next.js/test/e2e/app-dir/fallback-prefetch/fallback-prefetch.test.ts
Tobias Koppers 4494261bd7 Remove devCacheControlNoCache experimental option (hard-code no-cache) (#91503)
### What?

Removes the `experimental.devCacheControlNoCache` config option entirely
and hard-codes `no-cache, must-revalidate` as the dev server
`Cache-Control` header value.

Previously the option controlled whether the dev server responded with:
- `no-store, must-revalidate` (default, `false`)
- `no-cache, must-revalidate` (opt-in, `true`)

This PR first flips the default to `true`, then removes the option
altogether — making `no-cache, must-revalidate` unconditional in all dev
code paths.

### Why?

`no-cache` is strictly better than `no-store` for the dev server:
- `no-cache` allows the browser to revalidate (conditional
`If-None-Match`/`If-Modified-Since` requests), letting the server
respond with `304 Not Modified` when nothing changed → faster page loads
during development.
- `no-store` forces a full re-fetch every time, discarding valid cached
responses.

Since `no-cache` is the correct behavior for all dev users, the toggle
has no remaining value and can be removed to simplify the codebase.

### How?

**Two commits:**

1. `bcec825` — Flip the default from `false` → `true`; update
tests/fixtures/manifest to reflect the new default.

2. `e6e919f` — Remove the option entirely:
- Deleted `devCacheControlNoCache?: boolean` from `ExperimentalConfig`
interface, `config-schema.ts` Zod schema, `defaultConfig`,
`NextConfigRuntime`, and `getNextConfigRuntime()`.
- Replaced all four conditional ternaries in `base-server.ts`,
`router-server.ts`, `pages-handler.ts`, and `app-page.ts` with the
hard-coded string `'no-cache, must-revalidate'`.
- Deleted the `dev-cache-control-no-cache-disabled` test suite (was
testing the `false` path which no longer exists).
- Simplified the remaining `dev-cache-control-no-cache` test (removed
experimental framing).
   - Synced `rspack-dev-tests-manifest.json`.

---------

Co-authored-by: Tobias Koppers <sokra@users.noreply.github.com>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Vercel <vercel[bot]@users.noreply.github.com>
2026-03-17 20:13:01 +01:00

32 lines
993 B
TypeScript

import { nextTestSetup } from 'e2e-utils'
describe('fallback-prefetch', () => {
const { next } = nextTestSetup({
files: __dirname,
})
it('should prefetch the page without errors', async () => {
let hasNetworkError = false
const browser = await next.browser('/', {
beforePageLoad: (page) => {
page.on('response', (response) => {
// 304 Not Modified is a valid revalidation response (from no-cache),
// not a network error
if (!response.ok() && response.status() !== 304) {
hasNetworkError = true
}
})
},
})
// set a flag on the window to ensure we don't perform an MPA navigation when navigating to the prefetched link
await browser.eval('window.beforeNav = 1')
await browser.elementById('link-to-random').click()
await browser.waitForElementByCss('#random-page')
expect(await browser.eval('window.beforeNav')).toBe(1)
expect(hasNetworkError).toBe(false)
})
})