相关疑难解决方法(0)

如何为 getServerSideProps 启用缓存?

我们有很少的页面和组件作为服务器端渲染。

我们尝试对少数 API 响应使用缓存。

export async function getServerSideProps(context) {
   const res = await getRequest(API.home)
   return {
     props: {
       "home": res?.data?.result
     },
   }
}
Run Code Online (Sandbox Code Playgroud)

Next.js 版本是 11.1。

有人可以建议我们如何实现缓存吗?

javascript server-side-rendering next.js

5
推荐指数
1
解决办法
1万
查看次数