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