0.1.2 • Published 11 years ago
cache-header-control v0.1.2
cache-header-control
Control the response cache header
Install
npm install cache-header-control --saveUsage
var express = require('express');
var setCacheHeader = require('cache-header-control');
var app = express();
app.use(function (req, res, next) {
// Sets `Cache-Control` header to `public, max-age=600` and `Expires` too
// 'minute' -> 10 minutes -> 600 seconds
setCacheHeader(res, 'minute');
next();
});
app.listen(3000, function () {
});setCacheHeader(responseObject, timeValue)
responseObject- the response object passed through by NodetimeValue- themax-age,Expiresvalue to set the headers. Can be the following types:false|undefined|null|''|0|negative number:-2,'-3'- sets value tono-cache, no-store, must-revalidatenumber- a number or a string can be parse to a number. Sets theCache-Controlheader topublic, max-age={number}andExpiresheader to{number}stringcan be:'minute'- 600(10 minutes)'hour'- 3600(1 hour) *'day'- 86400(1 day)
Run Tests
npm install
npm test