Unverified Commit 4ba05cc3 authored by Zack Tanner's avatar Zack Tanner Committed by GitHub

enable validateRSCRequestHeaders by default (#93367)

This flag has been enabled by default on canary for some time. This
turns it on by default to ensure that CDNs that don't respect `Vary`
properly distinguish between different response types.
parent f3f7c7c0
...@@ -74,7 +74,7 @@ These headers can be omitted in specific cases without causing protocol errors. ...@@ -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. **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. > **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.
......
...@@ -13,7 +13,6 @@ import type { SizeLimit } from '../types' ...@@ -13,7 +13,6 @@ import type { SizeLimit } from '../types'
import type { SupportedTestRunners } from '../cli/next-test' import type { SupportedTestRunners } from '../cli/next-test'
import type { ExperimentalPPRConfig } from './lib/experimental/ppr' import type { ExperimentalPPRConfig } from './lib/experimental/ppr'
import { INFINITE_CACHE } from '../lib/constants' import { INFINITE_CACHE } from '../lib/constants'
import { isStableBuild } from '../shared/lib/errors/canary-only-config-error'
import type { FallbackRouteParam } from '../build/static-paths/types' import type { FallbackRouteParam } from '../build/static-paths/types'
/** /**
...@@ -1941,9 +1940,7 @@ export const defaultConfig = Object.freeze({ ...@@ -1941,9 +1940,7 @@ export const defaultConfig = Object.freeze({
strictRouteTypes: false, strictRouteTypes: false,
viewTransition: false, viewTransition: false,
removeUncaughtErrorAndRejectionListeners: false, removeUncaughtErrorAndRejectionListeners: false,
validateRSCRequestHeaders: !!( validateRSCRequestHeaders: true,
process.env.__NEXT_TEST_MODE || !isStableBuild()
),
staleTimes: { staleTimes: {
dynamic: 0, dynamic: 0,
static: 300, static: 300,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment