如何缓存expressjs响应

coo*_*ool 5 caching node.js express

如何缓存由 expressjs 路由生成的响应。这条路线有很多数据库访问,对它的更改很少。是否有任何可用的节点模块。

谢谢

az7*_*7ar 4

connect-cache应该可以解决问题。将其作为中间件添加到您的应用程序中

var connect_cache = require('connect-cache');
app.use(
connect_cache({rules: [{regex: /.*/, ttl: 60000}]})
);
Run Code Online (Sandbox Code Playgroud)