From 17c94ecea75ad94db543ed99628c8e9d7c5a7de0 Mon Sep 17 00:00:00 2001 From: Zack Tanner Date: Wed, 15 Nov 2023 16:38:12 -0800 Subject: [PATCH] skip flushToDisk in minimal mode for fetch cache --- .../helpers/create-incremental-cache.ts | 28 +++++++++++++------ packages/next/src/export/worker.ts | 9 ++++-- 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/packages/next/src/export/helpers/create-incremental-cache.ts b/packages/next/src/export/helpers/create-incremental-cache.ts index d959dee0aad52..8228005f4a3bc 100644 --- a/packages/next/src/export/helpers/create-incremental-cache.ts +++ b/packages/next/src/export/helpers/create-incremental-cache.ts @@ -5,15 +5,25 @@ import { IncrementalCache } from '../../server/lib/incremental-cache' import { hasNextSupport } from '../../telemetry/ci-info' import { nodeFs } from '../../server/lib/node-fs-methods' -export function createIncrementalCache( - incrementalCacheHandlerPath: string | undefined, - isrMemoryCacheSize: number | undefined, - fetchCacheKeyPrefix: string | undefined, - distDir: string, - dir: string, - enabledDirectories: NextEnabledDirectories, +export function createIncrementalCache({ + incrementalCacheHandlerPath, + isrMemoryCacheSize, + fetchCacheKeyPrefix, + distDir, + dir, + enabledDirectories, + experimental, + flushToDisk, +}: { + incrementalCacheHandlerPath?: string + isrMemoryCacheSize?: number + fetchCacheKeyPrefix?: string + distDir: string + dir: string + enabledDirectories: NextEnabledDirectories experimental: { ppr: boolean } -) { + flushToDisk?: boolean +}) { // Custom cache handler overrides. let CacheHandler: any if (incrementalCacheHandlerPath) { @@ -26,7 +36,7 @@ export function createIncrementalCache( const incrementalCache = new IncrementalCache({ dev: false, requestHeaders: {}, - flushToDisk: true, + flushToDisk, fetchCache: true, maxMemoryCacheSize: isrMemoryCacheSize, fetchCacheKeyPrefix, diff --git a/packages/next/src/export/worker.ts b/packages/next/src/export/worker.ts index b12b170aa15e8..2ab330d52c8e4 100644 --- a/packages/next/src/export/worker.ts +++ b/packages/next/src/export/worker.ts @@ -218,7 +218,7 @@ async function exportPageImpl( // cache instance for this page. const incrementalCache = isAppDir && fetchCache - ? createIncrementalCache( + ? createIncrementalCache({ incrementalCacheHandlerPath, isrMemoryCacheSize, fetchCacheKeyPrefix, @@ -226,8 +226,11 @@ async function exportPageImpl( dir, enabledDirectories, // PPR is not available for Pages. - { ppr: false } - ) + experimental: { ppr: false }, + // skip writing to disk in minimal mode for now, pending some + // changes to better support it + flushToDisk: !hasNextSupport, + }) : undefined // Handle App Routes.