Comparing version
10
index.js
@@ -0,4 +1,12 @@ | ||
var deprecate = require('depd')('nocache') | ||
module.exports = function nocache (options) { | ||
var noEtag = (options || {}).noEtag | ||
options = options || {} | ||
if (options.hasOwnProperty('noEtag')) { | ||
deprecate('noEtag will be removed in the next version of nocache. Please remove this option.') | ||
} | ||
var noEtag = options.noEtag | ||
return function nocache (req, res, next) { | ||
@@ -5,0 +13,0 @@ res.setHeader('Surrogate-Control', 'no-store') |
@@ -8,3 +8,3 @@ { | ||
"description": "Middleware to destroy caching", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"license": "MIT", | ||
@@ -26,3 +26,4 @@ "keywords": [ | ||
"scripts": { | ||
"test": "standard && mocha" | ||
"pretest": "standard", | ||
"test": "mocha" | ||
}, | ||
@@ -40,3 +41,6 @@ "devDependencies": { | ||
] | ||
}, | ||
"dependencies": { | ||
"depd": "1.1.0" | ||
} | ||
} |
@@ -6,2 +6,4 @@ Middleware to turn off caching | ||
[_Looking for a changelog?_](https://github.com/helmetjs/helmet/blob/master/HISTORY.md) | ||
It's possible that you've got bugs in an old HTML or JavaScript file, and with a cache, some users will be stuck with those old versions. This will (try to) abolish all client-side caching. | ||
@@ -21,8 +23,2 @@ | ||
If you want to crush the `ETag` header as well, you can: | ||
```javascript | ||
app.use(nocache({ noEtag: true })) | ||
``` | ||
Caching has some real benefits, and you lose many of them here. Browsers won't cache resources with this enabled, although *some* performance is retained if you keep ETag support. It's also possible that you'll introduce *new* bugs and you'll wish people had old resources cached, but that's less likely. | ||
Caching has performance benefits, and you lose them here. It's also possible that you'll introduce *new* bugs and you'll wish people had old resources cached, but that's less likely. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
3635
-27.86%1
Infinity%5
-28.57%18
-71.43%23
-14.81%+ Added
+ Added