首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >使用自定义服务器的Next.js SSR缓存

使用自定义服务器的Next.js SSR缓存
EN

Stack Overflow用户
提问于 2021-05-28 17:20:32
回答 1查看 816关注 0票数 0

我如何在SSR上实现缓存,因为他们提到了app.renderToHTML()缓存不起作用,显然,Next.js已经使Next.js过时了,不能与getServerSideProps函数一起使用,并且在缓存函数中使用app.render(),而缓存函数中总是会出现未定义和中断的情况。

代码语言:javascript
运行
复制
(node:20872) UnhandledPromiseRejectionWarning: TypeError: argument entity is required
at etag (C:\xampp\htdocs\next-app\node_modules\etag\index.js:72:11)
at C:\xampp\htdocs\next-app\node_modules\cacheable-response\index.js:93:32
at processTicksAndRejections (internal/process/task_queues.js:93:5)
(Use node --trace-warnings ... to show where the warning was created)
(node:20872) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:20872) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

因为上面的例子破了。

这里是github链接,我在这里提出了一个问题https://github.com/vercel/next.js/issues/25579

有人能帮我吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-06-23 08:00:47

github上的@ 解决方案 481建议的这个github似乎解决了这个问题,我可以确认缓存也在工作。我测试了它,在cachableResponsecachableResponse方法中放置了一个跟踪,这个方法只在没有缓存响应的情况下才会被调用。

同时通过邮递员测试博客页面,在第一次调用和响应时间从X-Cache-Status减少到<20后,我得到了标题>300作为HIT

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67743149

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档