我如何在SSR上实现缓存,因为他们提到了app.renderToHTML()缓存不起作用,显然,Next.js已经使Next.js过时了,不能与getServerSideProps函数一起使用,并且在缓存函数中使用app.render(),而缓存函数中总是会出现未定义和中断的情况。
(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
有人能帮我吗?
发布于 2021-06-23 00:00:47
github上的@ 解决方案 481建议的这个github似乎解决了这个问题,我可以确认缓存也在工作。我测试了它,在cachableResponse
的cachableResponse
方法中放置了一个跟踪,这个方法只在没有缓存响应的情况下才会被调用。
同时通过邮递员测试博客页面,在第一次调用和响应时间从X-Cache-Status
减少到<20
后,我得到了标题>300
作为HIT
https://stackoverflow.com/questions/67743149
复制相似问题