Skip to content

turbopackFileSystemCache

用法

¥Usage

Turbopack 文件系统缓存使 Turbopack 能够减少 next devnext build 命令的执行量。启用后,Turbopack 会在构建之间将数据保存并恢复到 .next 文件夹,这可以大大加快后续构建和开发会话的速度。

¥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.

需要了解:文件系统缓存功能在开发环境中被认为是稳定的,但在生产环境中仍处于实验阶段。

¥Good to know: The FileSystem Cache feature is considered stable for development and experimental for production builds

ts
import type { NextConfig } from 'next'

const nextConfig: NextConfig = {
  experimental: {
    // Enable filesystem caching for `next dev`
    turbopackFileSystemCacheForDev: true,
    // Enable filesystem caching for `next build`
    turbopackFileSystemCacheForBuild: true,
  },
}

export default nextConfig

版本变更

¥Version Changes

版本更改
v16.1.0默认情况下,文件系统缓存已启用(用于开发环境)。
v16.0.0Beta 版本,构建和开发分别使用不同的标志
v15.5.0持久缓存功能已在 Canary 版本中作为实验性功能发布。