diff --git a/docs/01-app/02-guides/cdn-caching.mdx b/docs/01-app/02-guides/cdn-caching.mdx index 2b274f5f853..858c32e42ef 100644 --- a/docs/01-app/02-guides/cdn-caching.mdx +++ b/docs/01-app/02-guides/cdn-caching.mdx @@ -74,7 +74,7 @@ These headers can be omitted in specific cases without causing protocol errors. **When `next-router-prefetch` is present, preserve both the prefetch header and the `_rsc` search parameter.** For prefetch flows, `_rsc` is a required cache-busting discriminator and should be treated as mandatory. -**The `_rsc` search parameter** must be included in the cache key. It distinguishes response variants (HTML vs. RSC, different prefetch types). Ensure your CDN does not strip query parameters from cache keys, as some CDNs do this by default. When the `experimental.validateRSCRequestHeaders` option is enabled and a RSC request arrives without the correct `_rsc` value, the server responds with a **307 redirect** to the URL with the correct hash. CDNs should follow this redirect. Platforms that compute the hash upstream can rewrite requests to include the correct `_rsc` before forwarding to avoid an extra round trip. +**The `_rsc` search parameter** must be included in the cache key. It distinguishes response variants (HTML vs. RSC, different prefetch types). Ensure your CDN does not strip query parameters from cache keys, as some CDNs do this by default. By default, when a RSC request arrives without the correct `_rsc` value, the server responds with a **307 redirect** to the URL with the correct hash. This behavior can be disabled by setting `experimental.validateRSCRequestHeaders` to `false`. CDNs should follow this redirect. Platforms that compute the hash upstream can rewrite requests to include the correct `_rsc` before forwarding to avoid an extra round trip. > **Good to know:** Today, `next-url` is included in the `_rsc` hash even during static prefetches. This means you cannot safely ignore it under the current scheme without potentially getting cache misses. The pathname-based direction described below resolves this gap. diff --git a/packages/next/src/server/config-shared.ts b/packages/next/src/server/config-shared.ts index 6bfc0919201..d9915e3036e 100644 --- a/packages/next/src/server/config-shared.ts +++ b/packages/next/src/server/config-shared.ts @@ -13,7 +13,6 @@ import type { SizeLimit } from '../types' import type { SupportedTestRunners } from '../cli/next-test' import type { ExperimentalPPRConfig } from './lib/experimental/ppr' import { INFINITE_CACHE } from '../lib/constants' -import { isStableBuild } from '../shared/lib/errors/canary-only-config-error' import type { FallbackRouteParam } from '../build/static-paths/types' /** @@ -1941,9 +1940,7 @@ export const defaultConfig = Object.freeze({ strictRouteTypes: false, viewTransition: false, removeUncaughtErrorAndRejectionListeners: false, - validateRSCRequestHeaders: !!( - process.env.__NEXT_TEST_MODE || !isStableBuild() - ), + validateRSCRequestHeaders: true, staleTimes: { dynamic: 0, static: 300,