Unverified Commit 7fa72048 authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Add config for opting out of optimistic client cache behavior (#38774)

* Add config for opting out of optimistic client cache behavior

* update test
parent 0de6269c
...@@ -1526,6 +1526,9 @@ export default async function getBaseWebpackConfig( ...@@ -1526,6 +1526,9 @@ export default async function getBaseWebpackConfig(
'process.env.__NEXT_NEW_LINK_BEHAVIOR': JSON.stringify( 'process.env.__NEXT_NEW_LINK_BEHAVIOR': JSON.stringify(
config.experimental.newNextLinkBehavior config.experimental.newNextLinkBehavior
), ),
'process.env.__NEXT_OPTIMISTIC_CLIENT_CACHE': JSON.stringify(
config.experimental.optimisticClientCache
),
'process.env.__NEXT_CROSS_ORIGIN': JSON.stringify(crossOrigin), 'process.env.__NEXT_CROSS_ORIGIN': JSON.stringify(crossOrigin),
'process.browser': JSON.stringify(isClient), 'process.browser': JSON.stringify(isClient),
'process.env.__NEXT_TEST_MODE': JSON.stringify( 'process.env.__NEXT_TEST_MODE': JSON.stringify(
......
...@@ -328,6 +328,9 @@ const configSchema = { ...@@ -328,6 +328,9 @@ const configSchema = {
}, },
] as any, ] as any,
}, },
optimisticClientCache: {
type: 'boolean',
},
outputFileTracingRoot: { outputFileTracingRoot: {
minLength: 1, minLength: 1,
type: 'string', type: 'string',
......
...@@ -79,6 +79,7 @@ export interface NextJsWebpackConfig { ...@@ -79,6 +79,7 @@ export interface NextJsWebpackConfig {
} }
export interface ExperimentalConfig { export interface ExperimentalConfig {
optimisticClientCache?: boolean
legacyBrowsers?: boolean legacyBrowsers?: boolean
browsersListForSwc?: boolean browsersListForSwc?: boolean
manualClientBasePath?: boolean manualClientBasePath?: boolean
...@@ -517,6 +518,7 @@ export const defaultConfig: NextConfig = { ...@@ -517,6 +518,7 @@ export const defaultConfig: NextConfig = {
swcMinify: false, swcMinify: false,
output: !!process.env.NEXT_PRIVATE_STANDALONE ? 'standalone' : undefined, output: !!process.env.NEXT_PRIVATE_STANDALONE ? 'standalone' : undefined,
experimental: { experimental: {
optimisticClientCache: true,
runtime: undefined, runtime: undefined,
manualClientBasePath: false, manualClientBasePath: false,
// TODO: change default in next major release (current v12.1.5) // TODO: change default in next major release (current v12.1.5)
......
...@@ -2158,7 +2158,9 @@ export default class Router implements BaseRouter { ...@@ -2158,7 +2158,9 @@ export default class Router implements BaseRouter {
persistCache: !this.isPreview, persistCache: !this.isPreview,
isPrefetch: true, isPrefetch: true,
unstable_skipClientCache: unstable_skipClientCache:
options.unstable_skipClientCache || options.priority, options.unstable_skipClientCache ||
(options.priority &&
!!process.env.__NEXT_OPTIMISTIC_CLIENT_CACHE),
}).then(() => false) }).then(() => false)
: false : false
}), }),
......
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