docs/01-app/03-api-reference/05-config/01-next-config-js/turbopackFileSystemCache.mdx
Turbopack FileSystem Cache enables Turbopack to reduce work across next dev or next build commands. When enabled, Turbopack will save and restore data under the .next directory between runs, which can greatly speed up subsequent builds and dev sessions.
Two options control the cache, one for next dev and one for next build. Both are enabled by default:
import type { NextConfig } from 'next'
const nextConfig: NextConfig = {
experimental: {
turbopackFileSystemCacheForDev: true,
turbopackFileSystemCacheForBuild: true,
},
}
export default nextConfig
/** @type {import('next').NextConfig} */
const nextConfig = {
experimental: {
turbopackFileSystemCacheForDev: true,
turbopackFileSystemCacheForBuild: true,
},
}
module.exports = nextConfig
turbopackFileSystemCacheForDev (default: true): caches Turbopack's work for next dev in .next/dev/cache/turbopack. Restarting the dev server reuses the previous compilation.turbopackFileSystemCacheForBuild (default: true): caches Turbopack's work for next build in .next/cache/turbopack. Subsequent builds start warm. See Build environments.Set either option to false to opt out.
The build cache lives in .next/cache. Builds only get faster when that directory is restored before each build.
.next/cache over unless you cache or mount it explicitly..next/cache.If your build environment never preserves .next/cache, set turbopackFileSystemCacheForBuild: false to skip writing a cache that will not be read.
| Version | Changes |
|---|---|
v16.3.0 | FileSystem caching is enabled by default for builds |
v16.1.0 | FileSystem caching is enabled by default for development |
v16.0.0 | Beta release with separate flags for build and dev |
v15.5.0 | Persistent caching released as experimental on canary releases |