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