我正在运行一个作业聚合器,我希望避免缓存我的帖子提要,因为它向我的用户显示过时的结果。我们在 Next.JS 上运行。
我已经搜索了他们的文档,但没有找到如何去做的方法......
有人有想法吗?
我假设它在 next.config.js 上,但我不知 Prop 体如何。
最佳答案
如果服务器端渲染,这似乎有效
Page.getInitialProps = async ({ store, res }) => {
if (res) {
// res available only at server
// no-store disable bfCache for any browser. So your HTML will not be cached
res.setHeader('Cache-Control', 'no-store');
}
await store.dispatch(action());
return {};
};
关于reactjs - 如何仅在 Next.JS 中禁用特定页面上的缓存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62257837/