Unverified Commit 2f052b16 authored by Zack Tanner's avatar Zack Tanner Committed by GitHub

fully remove clientSegmentCache flag (#85541)

Turning this flag off would have already caused client-side invariants
because we deleted all the old codepaths. This fully removes the
remaining plumbing that supported the flag.
parent 953645ef
...@@ -188,8 +188,6 @@ For example, you may still want to have consistent usage of `<Link>` in your app ...@@ -188,8 +188,6 @@ For example, you may still want to have consistent usage of `<Link>` in your app
## Prefetching optimizations ## Prefetching optimizations
> **Good to know:** Layout deduplication and prefetch scheduling are part of upcoming optimizations. Currently available in Next.js canary via the `experimental.clientSegmentCache` flag.
### Client cache ### Client cache
Next.js stores prefetched React Server Component payloads in memory, keyed by route segments. When navigating between sibling routes (e.g. `/dashboard/settings` → `/dashboard/analytics`), it reuses the parent layout and only fetches the updated leaf page. This reduces network traffic and improves navigation speed. Next.js stores prefetched React Server Component payloads in memory, keyed by route segments. When navigating between sibling routes (e.g. `/dashboard/settings` → `/dashboard/analytics`), it reuses the parent layout and only fetches the updated leaf page. This reduces network traffic and improves navigation speed.
......
...@@ -902,5 +902,6 @@ ...@@ -902,5 +902,6 @@
"901": "Invalid \"cacheHandlers\" provided, expected an object e.g. { default: '/my-handler.js' }, received %s", "901": "Invalid \"cacheHandlers\" provided, expected an object e.g. { default: '/my-handler.js' }, received %s",
"902": "Invalid handler fields configured for \"cacheHandlers\":\\n%s", "902": "Invalid handler fields configured for \"cacheHandlers\":\\n%s",
"903": "The file \"%s\" must export a function, either as a default export or as a named \"%s\" export.\\nThis function is what Next.js runs for every request handled by this %s.\\n\\nWhy this happens:\\n%s- The file exists but doesn't export a function.\\n- The export is not a function (e.g., an object or constant).\\n- There's a syntax error preventing the export from being recognized.\\n\\nTo fix it:\\n- Ensure this file has either a default or \"%s\" function export.\\n\\nLearn more: https://nextjs.org/docs/messages/middleware-to-proxy", "903": "The file \"%s\" must export a function, either as a default export or as a named \"%s\" export.\\nThis function is what Next.js runs for every request handled by this %s.\\n\\nWhy this happens:\\n%s- The file exists but doesn't export a function.\\n- The export is not a function (e.g., an object or constant).\\n- There's a syntax error preventing the export from being recognized.\\n\\nTo fix it:\\n- Ensure this file has either a default or \"%s\" function export.\\n\\nLearn more: https://nextjs.org/docs/messages/middleware-to-proxy",
"904": "The file \"%s\" must export a function, either as a default export or as a named \"%s\" export." "904": "The file \"%s\" must export a function, either as a default export or as a named \"%s\" export.",
"905": "Page \"%s\" cannot use \\`export const unstable_prefetch = ...\\` without enabling \\`cacheComponents\\`."
} }
...@@ -1514,12 +1514,7 @@ export async function handleBuildComplete({ ...@@ -1514,12 +1514,7 @@ export async function handleBuildComplete({
route.page route.page
) + getDestinationQuery(route.routeKeys) ) + getDestinationQuery(route.routeKeys)
if ( if (appPageKeys && appPageKeys.length > 0 && config.cacheComponents) {
appPageKeys &&
appPageKeys.length > 0 &&
(config.experimental.cacheComponents ||
config.experimental.clientSegmentCache)
) {
// If we have fallback root params (implying we've already // If we have fallback root params (implying we've already
// emitted a rewrite for the /_tree request), or if the route // emitted a rewrite for the /_tree request), or if the route
// has PPR enabled and client param parsing is enabled, then // has PPR enabled and client param parsing is enabled, then
......
...@@ -681,14 +681,9 @@ export async function getAppPageStaticInfo({ ...@@ -681,14 +681,9 @@ export async function getAppPageStaticInfo({
) )
} }
if ( if ('unstable_prefetch' in config && !nextConfig.cacheComponents) {
'unstable_prefetch' in config &&
(!nextConfig.cacheComponents ||
// don't allow in `clientSegmentCache: 'client-only'` mode
nextConfig.experimental?.clientSegmentCache !== true)
) {
throw new Error( throw new Error(
`Page "${page}" cannot use \`export const unstable_prefetch = ...\` without enabling \`cacheComponents\` and \`experimental.clientSegmentCache\`.` `Page "${page}" cannot use \`export const unstable_prefetch = ...\` without enabling \`cacheComponents\`.`
) )
} }
......
...@@ -198,9 +198,6 @@ export function getDefineEnv({ ...@@ -198,9 +198,6 @@ export function getDefineEnv({
clientRouterFilters?.staticFilter ?? false, clientRouterFilters?.staticFilter ?? false,
'process.env.__NEXT_CLIENT_ROUTER_D_FILTER': 'process.env.__NEXT_CLIENT_ROUTER_D_FILTER':
clientRouterFilters?.dynamicFilter ?? false, clientRouterFilters?.dynamicFilter ?? false,
'process.env.__NEXT_CLIENT_SEGMENT_CACHE': Boolean(
config.experimental.clientSegmentCache
),
'process.env.__NEXT_CLIENT_VALIDATE_RSC_REQUEST_HEADERS': Boolean( 'process.env.__NEXT_CLIENT_VALIDATE_RSC_REQUEST_HEADERS': Boolean(
config.experimental.validateRSCRequestHeaders config.experimental.validateRSCRequestHeaders
), ),
......
...@@ -3000,10 +3000,7 @@ export default async function build( ...@@ -3000,10 +3000,7 @@ export default async function build(
// following enabled. This is because the flight data now // following enabled. This is because the flight data now
// does not contain any of the route params and is instead // does not contain any of the route params and is instead
// completely static. // completely static.
!( !config.cacheComponents
config.experimental.clientSegmentCache &&
config.cacheComponents
)
) { ) {
return return
} }
...@@ -3311,16 +3308,12 @@ export default async function build( ...@@ -3311,16 +3308,12 @@ export default async function build(
if ( if (
!isAppRouteHandler && !isAppRouteHandler &&
isAppPPREnabled && isAppPPREnabled &&
// Don't add a prefetch data route if we have both // Don't add a prefetch data route if we have
// clientSegmentCache and clientParamParsing enabled. This is // cacheComponents enabled. This is
// because we don't actually use the prefetch data route in // because we don't actually use the prefetch data route in
// this case. This only applies if we have PPR enabled for // this case. This only applies if we have PPR enabled for
// this route. // this route.
!( !(config.cacheComponents && isRoutePPREnabled)
config.experimental.clientSegmentCache &&
config.cacheComponents &&
isRoutePPREnabled
)
) { ) {
prefetchDataRoute = path.posix.join( prefetchDataRoute = path.posix.join(
`${normalizedRoute}${RSC_PREFETCH_SUFFIX}` `${normalizedRoute}${RSC_PREFETCH_SUFFIX}`
...@@ -3422,12 +3415,11 @@ export default async function build( ...@@ -3422,12 +3415,11 @@ export default async function build(
) )
if (!isAppRouteHandler && isAppPPREnabled) { if (!isAppRouteHandler && isAppPPREnabled) {
if ( if (
// Don't add a prefetch data route if we have both // Don't add a prefetch data route if we have
// clientSegmentCache and clientParamParsing enabled. This is // cacheComponents enabled. This is
// because we don't actually use the prefetch data route in // because we don't actually use the prefetch data route in
// this case. This only applies if we have PPR enabled for // this case. This only applies if we have PPR enabled for
// this route. // this route.
!config.experimental.clientSegmentCache ||
!config.cacheComponents || !config.cacheComponents ||
!isRoutePPREnabled !isRoutePPREnabled
) { ) {
......
...@@ -126,7 +126,6 @@ const AppSegmentConfigSchema = z.object({ ...@@ -126,7 +126,6 @@ const AppSegmentConfigSchema = z.object({
/** /**
* How this segment should be prefetched. * How this segment should be prefetched.
* (only applicable when `clientSegmentCache` is enabled)
*/ */
unstable_prefetch: PrefetchSchema.optional(), unstable_prefetch: PrefetchSchema.optional(),
...@@ -224,7 +223,6 @@ export type AppSegmentConfig = { ...@@ -224,7 +223,6 @@ export type AppSegmentConfig = {
/** /**
* How this segment should be prefetched. * How this segment should be prefetched.
* (only applicable when `clientSegmentCache` is enabled)
*/ */
unstable_prefetch?: Prefetch unstable_prefetch?: Prefetch
......
...@@ -563,9 +563,6 @@ export async function handler( ...@@ -563,9 +563,6 @@ export async function handler(
isRoutePPREnabled, isRoutePPREnabled,
expireTime: nextConfig.expireTime, expireTime: nextConfig.expireTime,
staleTimes: nextConfig.experimental.staleTimes, staleTimes: nextConfig.experimental.staleTimes,
clientSegmentCache: Boolean(
nextConfig.experimental.clientSegmentCache
),
dynamicOnHover: Boolean(nextConfig.experimental.dynamicOnHover), dynamicOnHover: Boolean(nextConfig.experimental.dynamicOnHover),
inlineCss: Boolean(nextConfig.experimental.inlineCss), inlineCss: Boolean(nextConfig.experimental.inlineCss),
authInterrupts: Boolean(nextConfig.experimental.authInterrupts), authInterrupts: Boolean(nextConfig.experimental.authInterrupts),
......
...@@ -158,7 +158,6 @@ async function requestHandler( ...@@ -158,7 +158,6 @@ async function requestHandler(
isRoutePPREnabled: false, isRoutePPREnabled: false,
expireTime: nextConfig.expireTime, expireTime: nextConfig.expireTime,
staleTimes: nextConfig.experimental.staleTimes, staleTimes: nextConfig.experimental.staleTimes,
clientSegmentCache: Boolean(nextConfig.experimental.clientSegmentCache),
dynamicOnHover: Boolean(nextConfig.experimental.dynamicOnHover), dynamicOnHover: Boolean(nextConfig.experimental.dynamicOnHover),
inlineCss: Boolean(nextConfig.experimental.inlineCss), inlineCss: Boolean(nextConfig.experimental.inlineCss),
authInterrupts: Boolean(nextConfig.experimental.authInterrupts), authInterrupts: Boolean(nextConfig.experimental.authInterrupts),
......
...@@ -746,10 +746,7 @@ export const useLinkStatus = () => { ...@@ -746,10 +746,7 @@ export const useLinkStatus = () => {
function getFetchStrategyFromPrefetchProp( function getFetchStrategyFromPrefetchProp(
prefetchProp: Exclude<LinkProps['prefetch'], undefined | false> prefetchProp: Exclude<LinkProps['prefetch'], undefined | false>
): PrefetchTaskFetchStrategy { ): PrefetchTaskFetchStrategy {
if ( if (process.env.__NEXT_CACHE_COMPONENTS) {
process.env.__NEXT_CACHE_COMPONENTS &&
process.env.__NEXT_CLIENT_SEGMENT_CACHE
) {
if (prefetchProp === true) { if (prefetchProp === true) {
return FetchStrategy.Full return FetchStrategy.Full
} }
...@@ -758,13 +755,10 @@ function getFetchStrategyFromPrefetchProp( ...@@ -758,13 +755,10 @@ function getFetchStrategyFromPrefetchProp(
// This will also include invalid prop values that don't match the types specified here. // This will also include invalid prop values that don't match the types specified here.
// (although those should've been filtered out by prop validation in dev) // (although those should've been filtered out by prop validation in dev)
prefetchProp satisfies null | 'auto' prefetchProp satisfies null | 'auto'
// In `clientSegmentCache`, we default to PPR, and we'll discover whether or not the route supports it with the initial prefetch.
// If we're not using `clientSegmentCache`, this will be converted into a `PrefetchKind.AUTO`.
return FetchStrategy.PPR return FetchStrategy.PPR
} else { } else {
return prefetchProp === null || prefetchProp === 'auto' return prefetchProp === null || prefetchProp === 'auto'
? // In `clientSegmentCache`, we default to PPR, and we'll discover whether or not the route supports it with the initial prefetch. ? // We default to PPR, and we'll discover whether or not the route supports it with the initial prefetch.
// If we're not using `clientSegmentCache`, this will be converted into a `PrefetchKind.AUTO`.
FetchStrategy.PPR FetchStrategy.PPR
: // In the old implementation without runtime prefetches, `prefetch={true}` forces all dynamic data to be prefetched. : // In the old implementation without runtime prefetches, `prefetch={true}` forces all dynamic data to be prefetched.
// To preserve backwards-compatibility, anything other than `false`, `null`, or `"auto"` results in a full prefetch. // To preserve backwards-compatibility, anything other than `false`, `null`, or `"auto"` results in a full prefetch.
......
...@@ -97,9 +97,7 @@ function HistoryUpdater({ ...@@ -97,9 +97,7 @@ function HistoryUpdater({
// task. Re-prefetch all visible links with the updated values. In most // task. Re-prefetch all visible links with the updated values. In most
// cases, this will not result in any new network requests, only if // cases, this will not result in any new network requests, only if
// the prefetch result actually varies on one of these inputs. // the prefetch result actually varies on one of these inputs.
if (process.env.__NEXT_CLIENT_SEGMENT_CACHE) {
pingVisibleLinks(appRouterState.nextUrl, appRouterState.tree) pingVisibleLinks(appRouterState.nextUrl, appRouterState.tree)
}
}, [appRouterState.nextUrl, appRouterState.tree]) }, [appRouterState.nextUrl, appRouterState.tree])
return null return null
......
...@@ -14,8 +14,6 @@ import { ...@@ -14,8 +14,6 @@ import {
reschedulePrefetchTask, reschedulePrefetchTask,
} from './segment-cache' } from './segment-cache'
import { startTransition } from 'react' import { startTransition } from 'react'
import { PrefetchKind } from './router-reducer/router-reducer-types'
import { InvariantError } from '../../shared/lib/invariant-error'
type LinkElement = HTMLAnchorElement | SVGAElement type LinkElement = HTMLAnchorElement | SVGAElement
...@@ -298,13 +296,6 @@ function rescheduleLinkPrefetch( ...@@ -298,13 +296,6 @@ function rescheduleLinkPrefetch(
return return
} }
if (!process.env.__NEXT_CLIENT_SEGMENT_CACHE) {
// The old prefetch implementation does not have different priority levels.
// Just schedule a new prefetch task.
prefetchWithOldCacheImplementation(instance)
return
}
const { getCurrentAppRouterState } = const { getCurrentAppRouterState } =
require('./app-router-instance') as typeof import('./app-router-instance') require('./app-router-instance') as typeof import('./app-router-instance')
...@@ -369,54 +360,3 @@ export function pingVisibleLinks( ...@@ -369,54 +360,3 @@ export function pingVisibleLinks(
) )
} }
} }
function prefetchWithOldCacheImplementation(instance: PrefetchableInstance) {
// This is the path used when the Segment Cache is not enabled.
if (typeof window === 'undefined') {
return
}
const doPrefetch = async () => {
// note that `appRouter.prefetch()` is currently sync,
// so we have to wrap this call in an async function to be able to catch() errors below.
let prefetchKind: PrefetchKind
switch (instance.fetchStrategy) {
case FetchStrategy.PPR: {
prefetchKind = PrefetchKind.AUTO
break
}
case FetchStrategy.Full: {
prefetchKind = PrefetchKind.FULL
break
}
case FetchStrategy.PPRRuntime: {
// We can only get here if Client Segment Cache is off, and in that case
// it shouldn't be possible for a link to request a runtime prefetch.
throw new InvariantError(
'FetchStrategy.PPRRuntime should never be used when `experimental.clientSegmentCache` is disabled'
)
}
default: {
instance.fetchStrategy satisfies never
// Unreachable, but otherwise typescript will consider the variable unassigned
prefetchKind = undefined!
}
}
return instance.router.prefetch(instance.prefetchHref, {
kind: prefetchKind,
})
}
// Prefetch the page if asked (only in the client)
// We need to handle a prefetch error here since we may be
// loading with priority which can reject but we don't
// want to force navigation since this is only a prefetch
doPrefetch().catch((err) => {
if (process.env.NODE_ENV !== 'production') {
// rethrow to show invalid URL errors
throw err
}
})
}
...@@ -24,92 +24,68 @@ export type { ...@@ -24,92 +24,68 @@ export type {
NormalizedSearch, NormalizedSearch,
} from './segment-cache-impl/cache-key' } from './segment-cache-impl/cache-key'
const notEnabled: any = () => {
throw new Error(
'Segment Cache experiment is not enabled. This is a bug in Next.js.'
)
}
export const prefetch: typeof import('./segment-cache-impl/prefetch').prefetch = export const prefetch: typeof import('./segment-cache-impl/prefetch').prefetch =
process.env.__NEXT_CLIENT_SEGMENT_CACHE function (...args) {
? function (...args) {
return ( return (
require('./segment-cache-impl/prefetch') as typeof import('./segment-cache-impl/prefetch') require('./segment-cache-impl/prefetch') as typeof import('./segment-cache-impl/prefetch')
).prefetch(...args) ).prefetch(...args)
} }
: notEnabled
export const navigate: typeof import('./segment-cache-impl/navigation').navigate = export const navigate: typeof import('./segment-cache-impl/navigation').navigate =
process.env.__NEXT_CLIENT_SEGMENT_CACHE function (...args) {
? function (...args) {
return ( return (
require('./segment-cache-impl/navigation') as typeof import('./segment-cache-impl/navigation') require('./segment-cache-impl/navigation') as typeof import('./segment-cache-impl/navigation')
).navigate(...args) ).navigate(...args)
} }
: notEnabled
export const revalidateEntireCache: typeof import('./segment-cache-impl/cache').revalidateEntireCache = export const revalidateEntireCache: typeof import('./segment-cache-impl/cache').revalidateEntireCache =
process.env.__NEXT_CLIENT_SEGMENT_CACHE function (...args) {
? function (...args) {
return ( return (
require('./segment-cache-impl/cache') as typeof import('./segment-cache-impl/cache') require('./segment-cache-impl/cache') as typeof import('./segment-cache-impl/cache')
).revalidateEntireCache(...args) ).revalidateEntireCache(...args)
} }
: notEnabled
export const getCurrentCacheVersion: typeof import('./segment-cache-impl/cache').getCurrentCacheVersion = export const getCurrentCacheVersion: typeof import('./segment-cache-impl/cache').getCurrentCacheVersion =
process.env.__NEXT_CLIENT_SEGMENT_CACHE function (...args) {
? function (...args) {
return ( return (
require('./segment-cache-impl/cache') as typeof import('./segment-cache-impl/cache') require('./segment-cache-impl/cache') as typeof import('./segment-cache-impl/cache')
).getCurrentCacheVersion(...args) ).getCurrentCacheVersion(...args)
} }
: notEnabled
export const schedulePrefetchTask: typeof import('./segment-cache-impl/scheduler').schedulePrefetchTask = export const schedulePrefetchTask: typeof import('./segment-cache-impl/scheduler').schedulePrefetchTask =
process.env.__NEXT_CLIENT_SEGMENT_CACHE function (...args) {
? function (...args) {
return ( return (
require('./segment-cache-impl/scheduler') as typeof import('./segment-cache-impl/scheduler') require('./segment-cache-impl/scheduler') as typeof import('./segment-cache-impl/scheduler')
).schedulePrefetchTask(...args) ).schedulePrefetchTask(...args)
} }
: notEnabled
export const cancelPrefetchTask: typeof import('./segment-cache-impl/scheduler').cancelPrefetchTask = export const cancelPrefetchTask: typeof import('./segment-cache-impl/scheduler').cancelPrefetchTask =
process.env.__NEXT_CLIENT_SEGMENT_CACHE function (...args) {
? function (...args) {
return ( return (
require('./segment-cache-impl/scheduler') as typeof import('./segment-cache-impl/scheduler') require('./segment-cache-impl/scheduler') as typeof import('./segment-cache-impl/scheduler')
).cancelPrefetchTask(...args) ).cancelPrefetchTask(...args)
} }
: notEnabled
export const reschedulePrefetchTask: typeof import('./segment-cache-impl/scheduler').reschedulePrefetchTask = export const reschedulePrefetchTask: typeof import('./segment-cache-impl/scheduler').reschedulePrefetchTask =
process.env.__NEXT_CLIENT_SEGMENT_CACHE function (...args) {
? function (...args) {
return ( return (
require('./segment-cache-impl/scheduler') as typeof import('./segment-cache-impl/scheduler') require('./segment-cache-impl/scheduler') as typeof import('./segment-cache-impl/scheduler')
).reschedulePrefetchTask(...args) ).reschedulePrefetchTask(...args)
} }
: notEnabled
export const isPrefetchTaskDirty: typeof import('./segment-cache-impl/scheduler').isPrefetchTaskDirty = export const isPrefetchTaskDirty: typeof import('./segment-cache-impl/scheduler').isPrefetchTaskDirty =
process.env.__NEXT_CLIENT_SEGMENT_CACHE function (...args) {
? function (...args) {
return ( return (
require('./segment-cache-impl/scheduler') as typeof import('./segment-cache-impl/scheduler') require('./segment-cache-impl/scheduler') as typeof import('./segment-cache-impl/scheduler')
).isPrefetchTaskDirty(...args) ).isPrefetchTaskDirty(...args)
} }
: notEnabled
export const createCacheKey: typeof import('./segment-cache-impl/cache-key').createCacheKey = export const createCacheKey: typeof import('./segment-cache-impl/cache-key').createCacheKey =
process.env.__NEXT_CLIENT_SEGMENT_CACHE function (...args) {
? function (...args) {
return ( return (
require('./segment-cache-impl/cache-key') as typeof import('./segment-cache-impl/cache-key') require('./segment-cache-impl/cache-key') as typeof import('./segment-cache-impl/cache-key')
).createCacheKey(...args) ).createCacheKey(...args)
} }
: notEnabled
/** /**
* Below are public constants. They're small enough that we don't need to * Below are public constants. They're small enough that we don't need to
......
...@@ -395,10 +395,6 @@ async function exportAppImpl( ...@@ -395,10 +395,6 @@ async function exportAppImpl(
clientTraceMetadata: nextConfig.experimental.clientTraceMetadata, clientTraceMetadata: nextConfig.experimental.clientTraceMetadata,
expireTime: nextConfig.expireTime, expireTime: nextConfig.expireTime,
staleTimes: nextConfig.experimental.staleTimes, staleTimes: nextConfig.experimental.staleTimes,
clientSegmentCache:
nextConfig.experimental.clientSegmentCache === 'client-only'
? 'client-only'
: Boolean(nextConfig.experimental.clientSegmentCache),
clientParamParsingOrigins: clientParamParsingOrigins:
nextConfig.experimental.clientParamParsingOrigins, nextConfig.experimental.clientParamParsingOrigins,
dynamicOnHover: nextConfig.experimental.dynamicOnHover ?? false, dynamicOnHover: nextConfig.experimental.dynamicOnHover ?? false,
......
...@@ -5381,17 +5381,7 @@ async function collectSegmentData( ...@@ -5381,17 +5381,7 @@ async function collectSegmentData(
// decomposed into a separate stream per segment. // decomposed into a separate stream per segment.
const clientReferenceManifest = renderOpts.clientReferenceManifest const clientReferenceManifest = renderOpts.clientReferenceManifest
if ( if (!clientReferenceManifest) {
!clientReferenceManifest ||
// Do not generate per-segment data unless the experimental Segment Cache
// flag is enabled.
//
// We also skip generating segment data if flag is set to "client-only",
// rather than true. (The "client-only" option only affects the behavior of
// the client-side implementation; per-segment prefetches are intentionally
// disabled in that configuration).
renderOpts.experimental.clientSegmentCache !== true
) {
return return
} }
......
...@@ -137,7 +137,6 @@ export interface RenderOptsPartial { ...@@ -137,7 +137,6 @@ export interface RenderOptsPartial {
expireTime: number | undefined expireTime: number | undefined
staleTimes: ExperimentalConfig['staleTimes'] | undefined staleTimes: ExperimentalConfig['staleTimes'] | undefined
clientTraceMetadata: string[] | undefined clientTraceMetadata: string[] | undefined
clientSegmentCache: boolean | 'client-only'
/** /**
* The origins that are allowed to write the rewritten headers when * The origins that are allowed to write the rewritten headers when
......
...@@ -421,7 +421,6 @@ export default abstract class Server< ...@@ -421,7 +421,6 @@ export default abstract class Server<
} }
private readonly isAppPPREnabled: boolean private readonly isAppPPREnabled: boolean
private readonly isAppSegmentPrefetchEnabled: boolean
/** /**
* This is used to persist cache scopes across * This is used to persist cache scopes across
...@@ -489,10 +488,6 @@ export default abstract class Server< ...@@ -489,10 +488,6 @@ export default abstract class Server<
this.enabledDirectories.app && this.enabledDirectories.app &&
checkIsAppPPREnabled(this.nextConfig.experimental.ppr) checkIsAppPPREnabled(this.nextConfig.experimental.ppr)
this.isAppSegmentPrefetchEnabled =
this.enabledDirectories.app &&
this.nextConfig.experimental.clientSegmentCache === true
this.normalizers = { this.normalizers = {
// We should normalize the pathname from the RSC prefix only in minimal // We should normalize the pathname from the RSC prefix only in minimal
// mode as otherwise that route is not exposed external to the server as // mode as otherwise that route is not exposed external to the server as
...@@ -505,8 +500,7 @@ export default abstract class Server< ...@@ -505,8 +500,7 @@ export default abstract class Server<
this.isAppPPREnabled && this.minimalMode this.isAppPPREnabled && this.minimalMode
? new PrefetchRSCPathnameNormalizer() ? new PrefetchRSCPathnameNormalizer()
: undefined, : undefined,
segmentPrefetchRSC: segmentPrefetchRSC: this.minimalMode
this.isAppSegmentPrefetchEnabled && this.minimalMode
? new SegmentPrefixRSCPathnameNormalizer() ? new SegmentPrefixRSCPathnameNormalizer()
: undefined, : undefined,
data: this.enabledDirectories.pages data: this.enabledDirectories.pages
...@@ -550,10 +544,6 @@ export default abstract class Server< ...@@ -550,10 +544,6 @@ export default abstract class Server<
expireTime: this.nextConfig.expireTime, expireTime: this.nextConfig.expireTime,
staleTimes: this.nextConfig.experimental.staleTimes, staleTimes: this.nextConfig.experimental.staleTimes,
clientTraceMetadata: this.nextConfig.experimental.clientTraceMetadata, clientTraceMetadata: this.nextConfig.experimental.clientTraceMetadata,
clientSegmentCache:
this.nextConfig.experimental.clientSegmentCache === 'client-only'
? 'client-only'
: Boolean(this.nextConfig.experimental.clientSegmentCache),
clientParamParsingOrigins: clientParamParsingOrigins:
this.nextConfig.experimental.clientParamParsingOrigins, this.nextConfig.experimental.clientParamParsingOrigins,
dynamicOnHover: this.nextConfig.experimental.dynamicOnHover ?? false, dynamicOnHover: this.nextConfig.experimental.dynamicOnHover ?? false,
......
...@@ -192,9 +192,6 @@ export const experimentalSchema = { ...@@ -192,9 +192,6 @@ export const experimentalSchema = {
memoryBasedWorkersCount: z.boolean().optional(), memoryBasedWorkersCount: z.boolean().optional(),
craCompat: z.boolean().optional(), craCompat: z.boolean().optional(),
caseSensitiveRoutes: z.boolean().optional(), caseSensitiveRoutes: z.boolean().optional(),
clientSegmentCache: z
.union([z.boolean(), z.literal('client-only')])
.optional(),
clientParamParsingOrigins: z.array(z.string()).optional(), clientParamParsingOrigins: z.array(z.string()).optional(),
dynamicOnHover: z.boolean().optional(), dynamicOnHover: z.boolean().optional(),
disableOptimizedLoading: z.boolean().optional(), disableOptimizedLoading: z.boolean().optional(),
......
...@@ -279,8 +279,6 @@ export interface ExperimentalConfig { ...@@ -279,8 +279,6 @@ export interface ExperimentalConfig {
prerenderEarlyExit?: boolean prerenderEarlyExit?: boolean
linkNoTouchStart?: boolean linkNoTouchStart?: boolean
caseSensitiveRoutes?: boolean caseSensitiveRoutes?: boolean
clientSegmentCache?: boolean | 'client-only'
/** /**
* The origins that are allowed to write the rewritten headers when * The origins that are allowed to write the rewritten headers when
* performing a non-relative rewrite. When undefined, no non-relative * performing a non-relative rewrite. When undefined, no non-relative
...@@ -1455,7 +1453,6 @@ export const defaultConfig = Object.freeze({ ...@@ -1455,7 +1453,6 @@ export const defaultConfig = Object.freeze({
serverSourceMaps: false, serverSourceMaps: false,
linkNoTouchStart: false, linkNoTouchStart: false,
caseSensitiveRoutes: false, caseSensitiveRoutes: false,
clientSegmentCache: true,
clientParamParsingOrigins: undefined, clientParamParsingOrigins: undefined,
dynamicOnHover: false, dynamicOnHover: false,
preloadEntriesOnStart: true, preloadEntriesOnStart: true,
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
*/ */
const nextConfig = { const nextConfig = {
cacheComponents: true, cacheComponents: true,
experimental: { clientSegmentCache: true },
} }
module.exports = nextConfig module.exports = nextConfig
...@@ -37,18 +37,16 @@ describe('rsc-redirect', () => { ...@@ -37,18 +37,16 @@ describe('rsc-redirect', () => {
// TODO: these tests aren't currently run at all during testing // TODO: these tests aren't currently run at all during testing
if (process.env.NODE_ENV === 'production') { if (process.env.NODE_ENV === 'production') {
describe.each([ describe.each([
{ cacheComponents: true, segmentCache: true }, { cacheComponents: true },
{ cacheComponents: true, segmentCache: false }, { cacheComponents: false },
{ cacheComponents: false, segmentCache: true },
{ cacheComponents: false, segmentCache: false },
] as const)( ] as const)(
'rsc-redirect /old-about -> /about (cacheComponents: $cacheComponents, segmentCache: $segmentCache)', 'rsc-redirect /old-about -> /about (cacheComponents: $cacheComponents)',
({ cacheComponents, segmentCache }) => { ({ cacheComponents }) => {
beforeAll(() => { beforeAll(() => {
// Write next.config.js with the current flags // Write next.config.js with the current flags
fs.writeFileSync( fs.writeFileSync(
configPath, configPath,
`module.exports = { experimental: { cacheComponents: ${cacheComponents}, clientSegmentCache: ${segmentCache} } }\n` `module.exports = { experimental: { cacheComponents: ${cacheComponents}} }\n`
) )
}) })
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
*/ */
const nextConfig = { const nextConfig = {
experimental: { experimental: {
clientSegmentCache: true,
validateRSCRequestHeaders: true, validateRSCRequestHeaders: true,
}, },
} }
......
...@@ -7,10 +7,6 @@ if (!BUILD_ID) { ...@@ -7,10 +7,6 @@ if (!BUILD_ID) {
* @type {import('next').NextConfig} * @type {import('next').NextConfig}
*/ */
const nextConfig = { const nextConfig = {
experimental: {
clientSegmentCache: true,
},
distDir: '.next.' + BUILD_ID, distDir: '.next.' + BUILD_ID,
async generateBuildId() { async generateBuildId() {
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
const nextConfig = { const nextConfig = {
cacheComponents: true, cacheComponents: true,
experimental: { experimental: {
clientSegmentCache: true,
dynamicOnHover: true, dynamicOnHover: true,
}, },
} }
......
...@@ -3,9 +3,6 @@ ...@@ -3,9 +3,6 @@
*/ */
const nextConfig = { const nextConfig = {
output: 'export', output: 'export',
experimental: {
clientSegmentCache: true,
},
} }
module.exports = nextConfig module.exports = nextConfig
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
*/ */
const nextConfig = { const nextConfig = {
cacheComponents: true, cacheComponents: true,
experimental: { clientSegmentCache: true },
} }
module.exports = nextConfig module.exports = nextConfig
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
*/ */
const nextConfig = { const nextConfig = {
cacheComponents: true, cacheComponents: true,
experimental: { clientSegmentCache: true },
async rewrites() { async rewrites() {
return [ return [
{ {
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
*/ */
const nextConfig = { const nextConfig = {
cacheComponents: true, cacheComponents: true,
experimental: { clientSegmentCache: true },
} }
module.exports = nextConfig module.exports = nextConfig
/** @type {import('next').NextConfig} */ /** @type {import('next').NextConfig} */
module.exports = { module.exports = {
experimental: {
clientSegmentCache: true,
},
productionBrowserSourceMaps: true, productionBrowserSourceMaps: true,
} }
...@@ -2,7 +2,6 @@ import type { NextConfig } from 'next' ...@@ -2,7 +2,6 @@ import type { NextConfig } from 'next'
const nextConfig: NextConfig = { const nextConfig: NextConfig = {
cacheComponents: true, cacheComponents: true,
experimental: { clientSegmentCache: true },
productionBrowserSourceMaps: true, productionBrowserSourceMaps: true,
} }
......
...@@ -2,7 +2,6 @@ import type { NextConfig } from 'next' ...@@ -2,7 +2,6 @@ import type { NextConfig } from 'next'
const nextConfig: NextConfig = { const nextConfig: NextConfig = {
cacheComponents: true, cacheComponents: true,
experimental: { clientSegmentCache: true },
productionBrowserSourceMaps: true, productionBrowserSourceMaps: true,
} }
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
*/ */
const nextConfig = { const nextConfig = {
cacheComponents: true, cacheComponents: true,
experimental: { clientSegmentCache: true },
} }
module.exports = nextConfig module.exports = nextConfig
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
*/ */
const nextConfig = { const nextConfig = {
cacheComponents: true, cacheComponents: true,
experimental: { clientSegmentCache: true },
} }
module.exports = nextConfig module.exports = nextConfig
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
*/ */
const nextConfig = { const nextConfig = {
cacheComponents: true, cacheComponents: true,
experimental: { clientSegmentCache: true },
} }
module.exports = nextConfig module.exports = nextConfig
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
const nextConfig = { const nextConfig = {
cacheComponents: true, cacheComponents: true,
experimental: { experimental: {
clientSegmentCache: true,
staleTimes: { staleTimes: {
dynamic: 30, dynamic: 30,
}, },
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
*/ */
const nextConfig = { const nextConfig = {
cacheComponents: true, cacheComponents: true,
experimental: { clientSegmentCache: true },
} }
module.exports = nextConfig module.exports = nextConfig
...@@ -55,10 +55,7 @@ describe.skip('required server files app router', () => { ...@@ -55,10 +55,7 @@ describe.skip('required server files app router', () => {
}, },
nextConfig: { nextConfig: {
cacheHandler: './cache-handler.js', cacheHandler: './cache-handler.js',
experimental: {
cacheComponents: true, cacheComponents: true,
clientSegmentCache: true,
},
output: 'standalone', output: 'standalone',
}, },
}) })
......
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