useCache
此功能目前在 Canary 管道中提供,並且可能會有所變動。請嘗試升級 Next.js,並在 GitHub 上分享您的意見回饋。
useCache
標記是 Next.js 中的一項實驗性功能,它使 use cache
指示詞 能夠獨立於 dynamicIO
使用。啟用後,即使 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
後,您可以使用下列快取函式和設定
use cache
指示詞- 搭配
use cache
的cacheLife
函式 cacheTag
函式
這是否有幫助?