Supplying the Cache-Control header in Express applications
Let's install it with the NPM package manager:
npm install express-cache-control
Enabling caching with the express-cache-control
middleware requires three straightforward steps:
Get the module:
CacheControl = require("express-cache-control")
Create an instance of the middleware:
var cache = new CacheControl().middleware;
Bind the middleware instance to the routes you want to enable caching for:
app.get('/contacts', cache('minutes',1), function(request, response) { var get_params = url.parse(request.url, true).query; if (Object.keys(get_params).length == 0) { _v1.list(Contact, response); } else { var key = Object.keys(get_params)[0]; var value = get_params[key]; JSON.stringify(_v2.query_by_arg(Contact, key, ...