coool
coool

Reputation: 8297

How to cache expressjs response

How to cache the response that was genereated by expressjs route. This route has a lot of database access and changes to it to it are very little. Is there any node module avaialble.

Thanks

Upvotes: 5

Views: 3556

Answers (1)

az7ar
az7ar

Reputation: 5237

connect-cache should do the trick. Add this to your app as a middleware

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

Upvotes: 4

Related Questions