NextJS中文文档 - UseCache
useCache 标志是 Next.js 中的一个实验性功能,它允许独立于 dynamicIO 使用 use cache 指令。启用后,即使 dynamicIO 已关闭,你也可以在应用程序中使用 use cache。
使用方法
要启用 useCache 标志,请在 next.config.ts 文件的 experimental 部分将其设置为 true:
ts
import type { NextConfig } from 'next'
const nextConfig: NextConfig = {
experimental: {
useCache: true,
},
}
export default nextConfig1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
当启用 useCache 时,你可以使用以下缓存函数和配置:
use cache指令- 与
use cache一起使用的cacheLife函数 cacheTag函数


