cache-control
Advanced tools
Comparing version 0.1.1 to 1.0.0
29
index.js
@@ -7,2 +7,3 @@ var path = require('path'); | ||
var regular = require('regular'); | ||
var onHeaders = require('on-headers'); | ||
@@ -16,17 +17,19 @@ module.exports = function (options) { | ||
var _rel = slash(pathname); | ||
_.each(Object.keys(options), function (globKey) { | ||
var _glob = slash(globKey); | ||
if (minimatch(_rel, _glob) && !matched) { | ||
var val = options[globKey]; | ||
matched = true; | ||
onHeaders(res, function () { | ||
res.setHeader('Cache-Control', 'public, max-age=300'); | ||
_.each(Object.keys(options), function (globKey) { | ||
var _glob = slash(globKey); | ||
if (val === false) res.setHeader('Cache-Control', 'no-cache'); | ||
else if (isNumber(val)) res.setHeader('Cache-Control', 'public, max-age=' + val.toString()); | ||
else if (_.isString(val)) res.setHeader('Cache-Control', val); | ||
} | ||
if (minimatch(_rel, _glob) && !matched) { | ||
var val = options[globKey]; | ||
matched = true; | ||
if (val === false) res.setHeader('Cache-Control', 'no-cache'); | ||
else if (isNumber(val)) res.setHeader('Cache-Control', 'public, max-age=' + val.toString()); | ||
else if (_.isString(val)) res.setHeader('Cache-Control', val); | ||
} | ||
}); | ||
}); | ||
if (!matched) res.setHeader('Cache-Control', 'public, max-age=300'); | ||
@@ -33,0 +36,0 @@ next(); |
{ | ||
"name": "cache-control", | ||
"version": "0.1.1", | ||
"version": "1.0.0", | ||
"description": "Express/Connect middleware to set url cache options with globs", | ||
@@ -37,2 +37,3 @@ "main": "index.js", | ||
"minimatch": "^0.4.0", | ||
"on-headers": "^1.0.0", | ||
"regular": "^0.1.6", | ||
@@ -39,0 +40,0 @@ "slasher": "^0.1.5" |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
5736
76
0
6
+ Addedon-headers@^1.0.0
+ Addedon-headers@1.0.2(transitive)