useCache

useCache 標誌是 Next.js 中的一項實驗性功能,它允許獨立於 dynamicIO 使用 use cache 指令。啟用後,即使關閉了 dynamicIO,您仍可在應用程式中使用 use cache

使用方法

要啟用 useCache 標誌,請在 next.config.ts 檔案的 experimental 區段中將其設為 true

next.config.ts
import type { NextConfig } from 'next'

const nextConfig: NextConfig = {
  experimental: {
    useCache: true,
  },
}

export default nextConfig

啟用 useCache 後,您可以使用以下快取函數和配置:

On this page