Skip to content

Commit

Permalink
Add experimental clientSegmentCache flag (vercel#72626)
Browse files Browse the repository at this point in the history
This will be used to gate a rewrite of the client cache that we've just
started. Eventually it should merge with the PPR rollout, but that's
already in active experimentation and we don't want to harm the PPR
rollout. This will also let us incrementally get to parity with the
existing implementation, instead of trying to reach parity in one big
step.

When enabled (and when a route is using PPR), prefetches will use a new
per-segment cache instead of the existing per-page cache.
  • Loading branch information
acdlite authored Nov 12, 2024
1 parent b16f604 commit 2b5d897
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/next/src/build/webpack/plugins/define-env-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,9 @@ export function getDefineEnv({
clientRouterFilters?.staticFilter ?? false,
'process.env.__NEXT_CLIENT_ROUTER_D_FILTER':
clientRouterFilters?.dynamicFilter ?? false,
'process.env.__NEXT_CLIENT_SEGMENT_CACHE': Boolean(
config.experimental.clientSegmentCache
),
'process.env.__NEXT_OPTIMISTIC_CLIENT_CACHE':
config.experimental.optimisticClientCache ?? true,
'process.env.__NEXT_MIDDLEWARE_PREFETCH':
Expand Down
1 change: 1 addition & 0 deletions packages/next/src/server/config-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ export const configSchema: zod.ZodType<NextConfig> = z.lazy(() =>
memoryBasedWorkersCount: z.boolean().optional(),
craCompat: z.boolean().optional(),
caseSensitiveRoutes: z.boolean().optional(),
clientSegmentCache: z.boolean().optional(),
disableOptimizedLoading: z.boolean().optional(),
disablePostcssPresetEnv: z.boolean().optional(),
dynamicIO: z.boolean().optional(),
Expand Down
2 changes: 2 additions & 0 deletions packages/next/src/server/config-shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ export interface ExperimentalConfig {
prerenderEarlyExit?: boolean
linkNoTouchStart?: boolean
caseSensitiveRoutes?: boolean
clientSegmentCache?: boolean
appDocumentPreloading?: boolean
preloadEntriesOnStart?: boolean
/** @default true */
Expand Down Expand Up @@ -1085,6 +1086,7 @@ export const defaultConfig: NextConfig = {
serverSourceMaps: false,
linkNoTouchStart: false,
caseSensitiveRoutes: false,
clientSegmentCache: false,
appDocumentPreloading: undefined,
preloadEntriesOnStart: true,
clientRouterFilter: true,
Expand Down

0 comments on commit 2b5d897

Please sign in to comment.