unstable_noStore (实验性)
unstable_noStore
可用于声明性地选择退出静态渲染,并指示特定组件不应被缓存。
值得注意的是:
unstable_noStore
等同于在fetch
上使用cache: 'no-store'
unstable_noStore
比export const dynamic = 'force-dynamic'
更受推荐,因为它更加精细,可以在每个组件的基础上使用
- 在
unstable_cache
内使用unstable_noStore
不会选择退出静态生成。相反,它会依据缓存配置来决定是否缓存结果。
用法
如果你不想为 fetch
传递额外的选项,如 cache: 'no-store'
或 next: { revalidate: 0 }
,你可以使用 noStore()
来替代所有这些用例。
版本历史
版本 | 变更 |
---|---|
v14.0.0 | 引入了 unstable_noStore 。 |