Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 5 commits into from Jul 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/next/build/webpack-config.ts
Expand Up @@ -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(
Expand Down
3 changes: 3 additions & 0 deletions packages/next/server/config-schema.ts
Expand Up @@ -328,6 +328,9 @@ const configSchema = {
},
] as any,
},
optimisticClientCache: {
type: 'boolean',
},
outputFileTracingRoot: {
minLength: 1,
type: 'string',
Expand Down
2 changes: 2 additions & 0 deletions packages/next/server/config-shared.ts
Expand Up @@ -79,6 +79,7 @@ export interface NextJsWebpackConfig {
}

export interface ExperimentalConfig {
optimisticClientCache?: boolean
legacyBrowsers?: boolean
browsersListForSwc?: boolean
manualClientBasePath?: boolean
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion packages/next/shared/lib/router/router.ts
Expand Up @@ -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
}),
Expand Down