|
| 1 | +--- |
| 2 | +title: Turbopack FileSystem Caching |
| 3 | +nav_title: turbopackFileSystemCache |
| 4 | +description: Learn how to enable FileSystem Caching for Turbopack builds |
| 5 | +version: canary |
| 6 | +--- |
| 7 | + |
| 8 | +## Usage |
| 9 | + |
| 10 | +Turbopack FileSystem Cache enables Turbopack to reduce work across `next dev` or `next build` commands. When enabled, Turbopack will save and restore data to the `.next` folder between builds, which can greatly speed up subsequent builds and dev sessions. |
| 11 | + |
| 12 | +> **Warning:** FileSystem Cache is still under development and is not yet stable. Users adopting should expect some stability issues. |
| 13 | +
|
| 14 | +> **Good to know**: Note that while `next dev` and `next build` can share cached data with each other, most cache entries are command-specific due to different configuration and environment variables. |
| 15 | +
|
| 16 | +```ts filename="next.config.ts" switcher |
| 17 | +import type { NextConfig } from 'next' |
| 18 | + |
| 19 | +const nextConfig: NextConfig = { |
| 20 | + experimental: { |
| 21 | + // Enable filesystem caching for `next dev` |
| 22 | + turbopackFileSystemCacheForDev: true, |
| 23 | + // Enable filesystem caching for `next build` |
| 24 | + turbopackFileSystemCacheForBuild: true, |
| 25 | + }, |
| 26 | +} |
| 27 | + |
| 28 | +export default nextConfig |
| 29 | +``` |
| 30 | + |
| 31 | +```js filename="next.config.js" switcher |
| 32 | +/** @type {import('next').NextConfig} */ |
| 33 | +const nextConfig = { |
| 34 | + experimental: { |
| 35 | + // Enable filesystem caching for `next dev` |
| 36 | + turbopackFileSystemCacheForDev: true, |
| 37 | + // Enable filesystem caching for `next build` |
| 38 | + turbopackFileSystemCacheForBuild: true, |
| 39 | + }, |
| 40 | +} |
| 41 | + |
| 42 | +module.exports = nextConfig |
| 43 | +``` |
| 44 | + |
| 45 | +## Version Changes |
| 46 | + |
| 47 | +| Version | Changes | |
| 48 | +| --------- | ------------------------------------------- | |
| 49 | +| `v16.0.0` | Separate flags for build and dev. | |
| 50 | +| `v15.5.0` | Persistent caching released as experimental | |
0 commit comments