Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 887
coool Avatar asked Oct 04 '22 14:10

coool


1 Answers

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}]})
);
like image 175
az7ar Avatar answered Oct 11 '22 13:10

az7ar