useCache
useCache
标志是 Next.js 中的一项实验性功能,使 use cache
指令 可以独立于 dynamicIO
使用。启用后,即使 dynamicIO
已关闭,你也可以在应用中使用 use cache
。
¥The useCache
flag is an experimental feature in Next.js that enables the use cache
directive to be used independently of dynamicIO
. When enabled, you can use use cache
in your application even if dynamicIO
is turned off.
用法
¥Usage
要启用 useCache
标志,请在 next.config.ts
文件的 experimental
部分中将其设置为 true
:
¥To enable the useCache
flag, set it to true
in the experimental
section of your next.config.ts
file:
import type { NextConfig } from 'next'
const nextConfig: NextConfig = {
experimental: {
useCache: true,
},
}
export default nextConfig
启用 useCache
后,你可以使用以下缓存功能和配置:
¥When useCache
is enabled, you can use the following cache functions and configurations:
-
¥The
use cache
directive -
cacheLife
功能 与use cache
¥The
cacheLife
function withuse cache
-
¥The
cacheTag
function