Unverified Commit 16dcebe7 authored by Lee Robinson's avatar Lee Robinson Committed by GitHub

Stabilize custom cache handlers and changing memory size. (#57953)

This PR stabilizes the previously introduced experimental config options
for providing a custom cache handler (for both ISR as well as the Data
Cache) and for disabling or configuring the in-memory cache size. The
example usage would be as follows:

```js
// next.config.js
module.exports = {
  cacheHandler: require.resolve('./cache-handler.js'),
  cacheMaxMemorySize: 0 // disable default in-memory caching
}
```

This PR also updates the documentation to better reflect how to use the
custom cache handler when self-hosting. Further information will be
added in a following PR that also includes a full example of a custom
cache handler that implements `revalidateTag` as well as passing in
custom cache tags. The API reference docs have been updated here, as
well as a version history added.

I also noticed that we currently have two duplicated versions of the ISR
docs in the Pages Router docs: both for rendering and for data fetching.
Data Fetching is the correct location for this page. There were no other
references to the rendering version in the docs, so that must have been
an accident. I'll need to a get a redirect going for that regardless.

Tests have been updated for `cacheHandler` and I added a new test for
`cacheMaxMemorySize`.

---------
Co-authored-by: 's avatarJiachi Liu <inbox@huozhi.im>
parent 8e216ecb
......@@ -146,10 +146,8 @@ To configure the ISR/Data Cache location when self-hosting, you can configure a
```jsx filename="next.config.js"
module.exports = {
experimental: {
incrementalCacheHandlerPath: require.resolve('./cache-handler.js'),
isrMemoryCacheSize: 0, // disable default in-memory caching
},
cacheHandler: require.resolve('./cache-handler.js'),
cacheMaxMemorySize: 0, // disable default in-memory caching
}
```
......
---
title: incrementalCacheHandlerPath
description: Configure the Next.js cache used for storing and revalidating data.
title: Custom Next.js Cache Handler
nav_title: cacheHandler
description: Configure the Next.js cache used for storing and revalidating data to use any external service like Redis, Memcached, or others.
---
In Next.js, the [default cache handler](/docs/app/building-your-application/data-fetching/fetching-caching-and-revalidating) uses the filesystem cache. This requires no configuration, however, you can customize the cache handler by using the `incrementalCacheHandlerPath` field in `next.config.js`.
In Next.js, the [default cache handler](/docs/app/building-your-application/data-fetching/fetching-caching-and-revalidating) for the Pages and App Router uses the filesystem cache. This requires no configuration, however, you can customize the cache handler by using the `cacheHandler` field in `next.config.js`.
```js filename="next.config.js"
module.exports = {
experimental: {
incrementalCacheHandlerPath: require.resolve('./cache-handler.js'),
},
cacheHandler: require.resolve('./cache-handler.js'),
cacheMaxMemorySize: 0, // disable default in-memory caching
}
```
Here's an example of a custom cache handler:
```js filename="cache-handler.js"
const cache = new Map()
module.exports = class CacheHandler {
constructor(options) {
this.options = options
this.cache = {}
}
async get(key) {
return cache.get(key)
}
async set(key, data) {
cache.set(key, {
value: data,
lastModified: Date.now(),
})
}
}
```
View an example of a [custom cache handler](/docs/app/building-your-application/deploying#configuring-caching) and learn more about implementation.
## API Reference
......@@ -55,6 +33,7 @@ Returns the cached value or `null` if not found.
| --------- | -------------- | -------------------------------- |
| `key` | `string` | The key to store the data under. |
| `data` | Data or `null` | The data to be cached. |
| `ctx` | `{ tags: [] }` | The cache tags provided. |
Returns `Promise<void>`.
......@@ -65,3 +44,16 @@ Returns `Promise<void>`.
| `tag` | `string` | The cache tag to revalidate. |
Returns `Promise<void>`. Learn more about [revalidating data](/docs/app/building-your-application/data-fetching/fetching-caching-and-revalidating) or the [`revalidateTag()`](/docs/app/api-reference/functions/revalidateTag) function.
**Good to know:**
- `revalidatePath` is a convenience layer on top of cache tags. Calling `revalidatePath` will call your `revalidateTag` function, which you can then choose if you want to tag cache keys based on the path.
## Version History
| Version | Changes |
| --------- | ------------------------------------------------------------------------ |
| `v14.1.0` | Renamed `cacheHandler` is stable. |
| `v13.4.0` | `incrementalCacheHandlerPath` (experimental) supports `revalidateTag`. |
| `v13.4.0` | `incrementalCacheHandlerPath` (experimental) supports standalone output. |
| `v12.2.0` | `incrementalCacheHandlerPath` (experimental) is added. |
---
title: Incremental Static Regeneration
description: 'Learn how to create or update static pages at runtime with Incremental Static Regeneration.'
title: Incremental Static Regeneration (ISR)
description: Learn how to create or update static pages at runtime with Incremental Static Regeneration.
---
<details>
......@@ -169,29 +169,13 @@ export async function getStaticProps() {
Incremental Static Regeneration (ISR) works on [self-hosted Next.js sites](/docs/pages/building-your-application/deploying#self-hosting) out of the box when you use `next start`.
You can use this approach when deploying to container orchestrators such as [Kubernetes](https://kubernetes.io/) or [HashiCorp Nomad](https://www.nomadproject.io/). By default, generated assets will be stored in-memory on each pod. This means that each pod will have its own copy of the static files. Stale data may be shown until that specific pod is hit by a request.
To ensure consistency across all pods, you can disable in-memory caching. This will inform the Next.js server to only leverage assets generated by ISR in the file system.
You can use a shared network mount in your Kubernetes pods (or similar setup) to reuse the same file-system cache between different containers. By sharing the same mount, the `.next` folder which contains the `next/image` cache will also be shared and re-used.
To disable in-memory caching, set `isrMemoryCacheSize` to `0` in your `next.config.js` file:
```js filename="next.config.js"
module.exports = {
experimental: {
// Defaults to 50MB
isrMemoryCacheSize: 0, // cache size in bytes
},
}
```
> **Good to know**: You might need to consider a race condition between multiple pods trying to update the cache at the same time, depending on how your shared mount is configured.
Learn more about [self-hosting Next.js](/docs/pages/building-your-application/deploying#self-hosting).
## Version History
| Version | Changes |
| --------- | --------------------------------------------------------------------------------------- |
| `v14.1.0` | Custom `cacheHandler` is stable. |
| `v12.2.0` | On-Demand ISR is stable |
| `v12.1.0` | On-Demand ISR added (beta). |
| `v12.0.0` | [Bot-aware ISR fallback](https://nextjs.org/blog/next-12#bot-aware-isr-fallback) added. |
......
......@@ -239,16 +239,16 @@ export async function collectBuildTraces({
)),
]
const { incrementalCacheHandlerPath } = config.experimental
const { cacheHandler } = config
// ensure we trace any dependencies needed for custom
// incremental cache handler
if (incrementalCacheHandlerPath) {
if (cacheHandler) {
sharedEntriesSet.push(
require.resolve(
path.isAbsolute(incrementalCacheHandlerPath)
? incrementalCacheHandlerPath
: path.join(dir, incrementalCacheHandlerPath)
path.isAbsolute(cacheHandler)
? cacheHandler
: path.join(dir, cacheHandler)
)
)
}
......
......@@ -414,8 +414,7 @@ export function getEdgeServerEntry(opts: {
pagesType: opts.pagesType,
appDirLoader: Buffer.from(opts.appDirLoader || '').toString('base64'),
sriEnabled: !opts.isDev && !!opts.config.experimental.sri?.algorithm,
incrementalCacheHandlerPath:
opts.config.experimental.incrementalCacheHandlerPath,
cacheHandler: opts.config.cacheHandler,
preferredRegion: opts.preferredRegion,
middlewareConfig: Buffer.from(
JSON.stringify(opts.middlewareConfig || {})
......
......@@ -1245,7 +1245,7 @@ export default async function build(
PAGES_MANIFEST
)
const { incrementalCacheHandlerPath } = config.experimental
const { cacheHandler } = config
const requiredServerFilesManifest = nextBuildSpan
.traceChild('generate-required-server-files')
......@@ -1260,12 +1260,12 @@ export default async function build(
compress: false,
}
: {}),
cacheHandler: cacheHandler
? path.relative(distDir, cacheHandler)
: config.cacheHandler,
experimental: {
...config.experimental,
trustHostHeader: ciEnvironment.hasNextSupport,
incrementalCacheHandlerPath: incrementalCacheHandlerPath
? path.relative(distDir, incrementalCacheHandlerPath)
: undefined,
// @ts-expect-error internal field TODO: fix this, should use a separate mechanism to pass the info.
isExperimentalCompile: isCompileMode,
......@@ -1523,11 +1523,11 @@ export default async function build(
if (config.experimental.staticWorkerRequestDeduping) {
let CacheHandler
if (incrementalCacheHandlerPath) {
if (cacheHandler) {
CacheHandler = interopDefault(
await import(
formatDynamicImportPath(dir, incrementalCacheHandlerPath)
).then((mod) => mod.default || mod)
await import(formatDynamicImportPath(dir, cacheHandler)).then(
(mod) => mod.default || mod
)
)
}
......@@ -1542,7 +1542,7 @@ export default async function build(
: config.experimental.isrFlushToDisk,
serverDistDir: path.join(distDir, 'server'),
fetchCacheKeyPrefix: config.experimental.fetchCacheKeyPrefix,
maxMemoryCacheSize: config.experimental.isrMemoryCacheSize,
maxMemoryCacheSize: config.cacheMaxMemorySize,
getPrerenderManifest: () => ({
version: -1 as any, // letting us know this doesn't conform to spec
routes: {},
......@@ -1840,13 +1840,11 @@ export default async function build(
pageRuntime,
edgeInfo,
pageType,
incrementalCacheHandlerPath:
config.experimental.incrementalCacheHandlerPath,
cacheHandler: config.cacheHandler,
isrFlushToDisk: ciEnvironment.hasNextSupport
? false
: config.experimental.isrFlushToDisk,
maxMemoryCacheSize:
config.experimental.isrMemoryCacheSize,
maxMemoryCacheSize: config.cacheMaxMemorySize,
nextConfigOutput: config.output,
ppr: config.experimental.ppr === true,
})
......
......@@ -1304,7 +1304,7 @@ export async function buildAppStaticPaths({
configFileName,
generateParams,
isrFlushToDisk,
incrementalCacheHandlerPath,
cacheHandler,
requestHeaders,
maxMemoryCacheSize,
fetchCacheKeyPrefix,
......@@ -1315,10 +1315,10 @@ export async function buildAppStaticPaths({
page: string
configFileName: string
generateParams: GenerateParamsResults
incrementalCacheHandlerPath?: string
distDir: string
isrFlushToDisk?: boolean
fetchCacheKeyPrefix?: string
cacheHandler?: string
maxMemoryCacheSize?: number
requestHeaders: IncrementalCache['requestHeaders']
ppr: boolean
......@@ -1328,11 +1328,11 @@ export async function buildAppStaticPaths({
let CacheHandler: any
if (incrementalCacheHandlerPath) {
if (cacheHandler) {
CacheHandler = interopDefault(
await import(
formatDynamicImportPath(dir, incrementalCacheHandlerPath)
).then((mod) => mod.default || mod)
await import(formatDynamicImportPath(dir, cacheHandler)).then(
(mod) => mod.default || mod
)
)
}
......@@ -1483,7 +1483,7 @@ export async function isPageStatic({
originalAppPath,
isrFlushToDisk,
maxMemoryCacheSize,
incrementalCacheHandlerPath,
cacheHandler,
ppr,
}: {
dir: string
......@@ -1501,7 +1501,7 @@ export async function isPageStatic({
originalAppPath?: string
isrFlushToDisk?: boolean
maxMemoryCacheSize?: number
incrementalCacheHandlerPath?: string
cacheHandler?: string
nextConfigOutput: 'standalone' | 'export'
ppr: boolean
}): Promise<{
......@@ -1667,7 +1667,7 @@ export async function isPageStatic({
requestHeaders: {},
isrFlushToDisk,
maxMemoryCacheSize,
incrementalCacheHandlerPath,
cacheHandler,
ppr,
ComponentMod,
}))
......
......@@ -24,7 +24,7 @@ export type EdgeSSRLoaderQuery = {
appDirLoader?: string
pagesType: PAGE_TYPES
sriEnabled: boolean
incrementalCacheHandlerPath?: string
cacheHandler?: string
preferredRegion: string | string[] | undefined
middlewareConfig: string
serverActions?: {
......@@ -76,7 +76,7 @@ const edgeSSRLoader: webpack.LoaderDefinitionFunction<EdgeSSRLoaderQuery> =
appDirLoader: appDirLoaderBase64,
pagesType,
sriEnabled,
incrementalCacheHandlerPath,
cacheHandler,
preferredRegion,
middlewareConfig: middlewareConfigBase64,
serverActions,
......@@ -158,7 +158,7 @@ const edgeSSRLoader: webpack.LoaderDefinitionFunction<EdgeSSRLoaderQuery> =
: JSON.stringify(serverActions),
},
{
incrementalCacheHandler: incrementalCacheHandlerPath ?? null,
incrementalCacheHandler: cacheHandler ?? null,
}
)
} else {
......@@ -187,7 +187,7 @@ const edgeSSRLoader: webpack.LoaderDefinitionFunction<EdgeSSRLoaderQuery> =
},
{
userland500Page: userland500Path,
incrementalCacheHandler: incrementalCacheHandlerPath ?? null,
incrementalCacheHandler: cacheHandler ?? null,
}
)
}
......
......@@ -8,8 +8,8 @@ import { interopDefault } from '../../lib/interop-default'
import { formatDynamicImportPath } from '../../lib/format-dynamic-import-path'
export async function createIncrementalCache({
incrementalCacheHandlerPath,
isrMemoryCacheSize,
cacheHandler,
cacheMaxMemorySize,
fetchCacheKeyPrefix,
distDir,
dir,
......@@ -17,8 +17,8 @@ export async function createIncrementalCache({
experimental,
flushToDisk,
}: {
incrementalCacheHandlerPath?: string
isrMemoryCacheSize?: number
cacheHandler?: string
cacheMaxMemorySize?: number
fetchCacheKeyPrefix?: string
distDir: string
dir: string
......@@ -28,11 +28,11 @@ export async function createIncrementalCache({
}) {
// Custom cache handler overrides.
let CacheHandler: any
if (incrementalCacheHandlerPath) {
if (cacheHandler) {
CacheHandler = interopDefault(
await import(
formatDynamicImportPath(dir, incrementalCacheHandlerPath)
).then((mod) => mod.default || mod)
await import(formatDynamicImportPath(dir, cacheHandler)).then(
(mod) => mod.default || mod
)
)
}
......@@ -41,7 +41,7 @@ export async function createIncrementalCache({
requestHeaders: {},
flushToDisk,
fetchCache: true,
maxMemoryCacheSize: isrMemoryCacheSize,
maxMemoryCacheSize: cacheMaxMemorySize,
fetchCacheKeyPrefix,
getPrerenderManifest: () => ({
version: 4,
......
......@@ -701,11 +701,10 @@ export async function exportAppImpl(
parentSpanId: pageExportSpan.getId(),
httpAgentOptions: nextConfig.httpAgentOptions,
debugOutput: options.debugOutput,
isrMemoryCacheSize: nextConfig.experimental.isrMemoryCacheSize,
cacheMaxMemorySize: nextConfig.cacheMaxMemorySize,
fetchCache: true,
fetchCacheKeyPrefix: nextConfig.experimental.fetchCacheKeyPrefix,
incrementalCacheHandlerPath:
nextConfig.experimental.incrementalCacheHandlerPath,
cacheHandler: nextConfig.cacheHandler,
enableExperimentalReact: needsExperimentalReact(nextConfig),
enabledDirectories,
})
......
......@@ -53,9 +53,9 @@ export interface ExportPageInput {
parentSpanId: any
httpAgentOptions: NextConfigComplete['httpAgentOptions']
debugOutput?: boolean
isrMemoryCacheSize?: NextConfigComplete['experimental']['isrMemoryCacheSize']
cacheMaxMemorySize?: NextConfigComplete['cacheMaxMemorySize']
fetchCache?: boolean
incrementalCacheHandlerPath?: string
cacheHandler?: string
fetchCacheKeyPrefix?: string
nextConfigOutput?: NextConfigComplete['output']
enableExperimentalReact?: boolean
......
......@@ -60,10 +60,10 @@ async function exportPageImpl(
optimizeCss,
disableOptimizedLoading,
debugOutput = false,
isrMemoryCacheSize,
cacheMaxMemorySize,
fetchCache,
fetchCacheKeyPrefix,
incrementalCacheHandlerPath,
cacheHandler,
enableExperimentalReact,
ampValidatorPath,
trailingSlash,
......@@ -222,8 +222,8 @@ async function exportPageImpl(
const incrementalCache =
isAppDir && fetchCache
? await createIncrementalCache({
incrementalCacheHandlerPath,
isrMemoryCacheSize,
cacheHandler,
cacheMaxMemorySize,
fetchCacheKeyPrefix,
distDir,
dir,
......
......@@ -117,6 +117,8 @@ export const configSchema: zod.ZodType<NextConfig> = z.lazy(() =>
analyticsId: z.string().optional(),
assetPrefix: z.string().optional(),
basePath: z.string().optional(),
cacheHandler: z.string().min(1).optional(),
cacheMaxMemorySize: z.number().optional(),
cleanDistDir: z.boolean().optional(),
compiler: z
.strictObject({
......@@ -266,9 +268,7 @@ export const configSchema: zod.ZodType<NextConfig> = z.lazy(() =>
forceSwcTransforms: z.boolean().optional(),
fullySpecified: z.boolean().optional(),
gzipSize: z.boolean().optional(),
incrementalCacheHandlerPath: z.string().optional(),
isrFlushToDisk: z.boolean().optional(),
isrMemoryCacheSize: z.number().optional(),
largePageDataBytes: z.number().optional(),
manualClientBasePath: z.boolean().optional(),
middlewarePrefetch: z.enum(['strict', 'flexible']).optional(),
......
......@@ -178,8 +178,6 @@ export interface ExperimentalConfig {
optimisticClientCache?: boolean
middlewarePrefetch?: 'strict' | 'flexible'
manualClientBasePath?: boolean
// custom path to a cache handler to use
incrementalCacheHandlerPath?: string
disablePostcssPresetEnv?: boolean
swcMinify?: boolean
cpus?: number
......@@ -203,12 +201,6 @@ export interface ExperimentalConfig {
gzipSize?: boolean
craCompat?: boolean
esmExternals?: boolean | 'loose'
/**
* In-memory cache size in bytes.
*
* If `isrMemoryCacheSize: 0` disables in-memory caching.
*/
isrMemoryCacheSize?: number
fullySpecified?: boolean
urlImports?: NonNullable<webpack.Configuration['experiments']>['buildHttp']
outputFileTracingRoot?: string
......@@ -507,6 +499,21 @@ export interface NextConfig extends Record<string, any> {
*/
assetPrefix?: string
/**
* The default cache handler for the Pages and App Router uses the filesystem cache. This requires no configuration, however, you can customize the cache handler if you prefer.
*
* @see [Configuring Caching](https://nextjs.org/docs/app/building-your-application/deploying#configuring-caching) and the [API Reference](https://nextjs.org/docs/app/api-reference/next-config-js/incrementalCacheHandlerPath).
*/
cacheHandler?: string | undefined
/**
* Configure the in-memory cache size in bytes. Defaults to 50 MB.
* If `cacheMaxMemorySize: 0`, this disables in-memory caching entirely.
*
* @see [Configuring Caching](https://nextjs.org/docs/app/building-your-application/deploying#configuring-caching).
*/
cacheMaxMemorySize?: number
/**
* By default, `Next` will serve each file in the `pages` folder under a pathname matching the filename.
* To disable this behavior and prevent routing based set this to `true`.
......@@ -749,6 +756,9 @@ export const defaultConfig: NextConfig = {
distDir: '.next',
cleanDistDir: true,
assetPrefix: '',
cacheHandler: undefined,
// default to 50MB limit
cacheMaxMemorySize: 50 * 1024 * 1024,
configOrigin: 'default',
useFileSystemPublicRoutes: true,
generateBuildId: () => null,
......@@ -819,9 +829,6 @@ export const defaultConfig: NextConfig = {
gzipSize: true,
craCompat: false,
esmExternals: true,
// default to 50MB limit
isrMemoryCacheSize: 50 * 1024 * 1024,
incrementalCacheHandlerPath: undefined,
fullySpecified: false,
outputFileTracingRoot: process.env.NEXT_PRIVATE_OUTPUT_TRACE_ROOT || '',
swcTraceProfiling: false,
......
......@@ -695,11 +695,10 @@ export default class DevServer extends Server {
page,
isAppPath,
requestHeaders,
incrementalCacheHandlerPath:
this.nextConfig.experimental.incrementalCacheHandlerPath,
cacheHandler: this.nextConfig.cacheHandler,
fetchCacheKeyPrefix: this.nextConfig.experimental.fetchCacheKeyPrefix,
isrFlushToDisk: this.nextConfig.experimental.isrFlushToDisk,
maxMemoryCacheSize: this.nextConfig.experimental.isrMemoryCacheSize,
maxMemoryCacheSize: this.nextConfig.cacheMaxMemorySize,
ppr: this.nextConfig.experimental.ppr === true,
})
return pathsResult
......
......@@ -37,7 +37,7 @@ export async function loadStaticPaths({
fetchCacheKeyPrefix,
maxMemoryCacheSize,
requestHeaders,
incrementalCacheHandlerPath,
cacheHandler,
ppr,
}: {
dir: string
......@@ -53,7 +53,7 @@ export async function loadStaticPaths({
fetchCacheKeyPrefix?: string
maxMemoryCacheSize?: number
requestHeaders: IncrementalCache['requestHeaders']
incrementalCacheHandlerPath?: string
cacheHandler?: string
ppr: boolean
}): Promise<{
paths?: string[]
......@@ -105,7 +105,7 @@ export async function loadStaticPaths({
configFileName: config.configFileName,
distDir,
requestHeaders,
incrementalCacheHandlerPath,
cacheHandler,
isrFlushToDisk,
fetchCacheKeyPrefix,
maxMemoryCacheSize,
......
......@@ -308,12 +308,12 @@ export default class NextNodeServer extends BaseServer {
}) {
const dev = !!this.renderOpts.dev
let CacheHandler: any
const { incrementalCacheHandlerPath } = this.nextConfig.experimental
const { cacheHandler } = this.nextConfig
if (incrementalCacheHandlerPath) {
if (cacheHandler) {
CacheHandler = interopDefault(
await dynamicImportEsmDefault(
formatDynamicImportPath(this.distDir, incrementalCacheHandlerPath)
formatDynamicImportPath(this.distDir, cacheHandler)
)
)
}
......@@ -334,7 +334,7 @@ export default class NextNodeServer extends BaseServer {
serverDistDir: this.serverDistDir,
fetchCache: true,
fetchCacheKeyPrefix: this.nextConfig.experimental.fetchCacheKeyPrefix,
maxMemoryCacheSize: this.nextConfig.experimental.isrMemoryCacheSize,
maxMemoryCacheSize: this.nextConfig.cacheMaxMemorySize,
flushToDisk:
!this.minimalMode && this.nextConfig.experimental.isrFlushToDisk,
getPrerenderManifest: () => this.getPrerenderManifest(),
......
......@@ -75,7 +75,7 @@ export default class NextWebServer extends BaseServer<WebServerOptions> {
minimalMode: this.minimalMode,
fetchCache: true,
fetchCacheKeyPrefix: this.nextConfig.experimental.fetchCacheKeyPrefix,
maxMemoryCacheSize: this.nextConfig.experimental.isrMemoryCacheSize,
maxMemoryCacheSize: this.nextConfig.cacheMaxMemorySize,
flushToDisk: false,
CurCacheHandler:
this.serverOptions.webServerConfig.incrementalCacheHandler,
......
module.exports = {
experimental: {
incrementalCacheHandlerPath:
process.cwd() + '/' + process.env.CUSTOM_CACHE_HANDLER,
},
cacheHandler: process.cwd() + '/' + process.env.CUSTOM_CACHE_HANDLER,
}
......@@ -3,9 +3,7 @@ module.exports = {
logging: {
fetches: {},
},
experimental: {
incrementalCacheHandlerPath: process.env.CUSTOM_CACHE_HANDLER,
},
cacheHandler: process.env.CUSTOM_CACHE_HANDLER,
rewrites: async () => {
return {
......
......@@ -38,9 +38,8 @@ describe('required server files app router', () => {
'.env.production': new FileRef(join(__dirname, '.env.production')),
},
nextConfig: {
experimental: {
incrementalCacheHandlerPath: './cache-handler.js',
},
cacheHandler: './cache-handler.js',
cacheMaxMemorySize: 0,
eslint: {
ignoreDuringBuilds: true,
},
......
......@@ -39,8 +39,8 @@ describe('required server files app router', () => {
'.env.production': new FileRef(join(__dirname, '.env.production')),
},
nextConfig: {
cacheHandler: './cache-handler.js',
experimental: {
incrementalCacheHandlerPath: './cache-handler.js',
ppr: true,
},
eslint: {
......
......@@ -45,9 +45,8 @@ describe('required server files', () => {
'.env.production': new FileRef(join(__dirname, '.env.production')),
},
nextConfig: {
experimental: {
incrementalCacheHandlerPath: './cache-handler.js',
},
cacheHandler: './cache-handler.js',
cacheMaxMemorySize: 0,
eslint: {
ignoreDuringBuilds: true,
},
......@@ -303,14 +302,20 @@ describe('required server files', () => {
).toContain('"compress":false')
})
it('`incrementalCacheHandlerPath` should have correct path', async () => {
it('`cacheHandler` should have correct path', async () => {
expect(
await fs.pathExists(join(next.testDir, 'standalone/cache-handler.js'))
).toBe(true)
expect(
await fs.readFileSync(join(next.testDir, 'standalone/server.js'), 'utf8')
).toContain('"incrementalCacheHandlerPath":"../cache-handler.js"')
).toContain('"cacheHandler":"../cache-handler.js"')
})
it('`cacheMaxMemorySize` should be disabled by setting to 0', async () => {
expect(
await fs.readFileSync(join(next.testDir, 'standalone/server.js'), 'utf8')
).toContain('"cacheMaxMemorySize":0')
})
it('should output middleware correctly', async () => {
......
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