express-quicklee is an express middleware for caching responses especially useful for responses that are coming from an outside source.
npm install --save express-quicklee
var app = express();
var quicklee = require('express-quicklee');
app.use(quicklee());
app.get('/', function (req, res) {
somePromiseWhichRetunsData(url).then(function(data) {
res.send(data); // data will be cached
});
});
You can also limit the size of the cache (default is no limit), and the selected strategy ('lru'
or 'lfu'
which is the default):
app.use(quicklee( { limit: 10000, strategy: 'lru' });