diff --git a/index.js b/index.js index 4d9ccae..2e757bd 100644 --- a/index.js +++ b/index.js @@ -68,6 +68,7 @@ module.exports = class CachePolicy { delete this._rescc['no-store']; delete this._rescc['must-revalidate']; this._resHeaders = Object.assign({}, this._resHeaders, {'cache-control': formatCacheControl(this._rescc)}); + delete this._resHeaders['pragma']; } // When the Cache-Control header field is not present in a request, caches MUST consider the no-cache request pragma-directive diff --git a/package.json b/package.json index f1837b7..ac1df20 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "http-cache-semantics", - "version": "3.3.1", + "version": "3.3.2", "description": "Parses Cache-Control headers and friends", "main": "index.js", "repository": "https://github.com/pornel/http-cache-semantics.git", diff --git a/test/responsetest.js b/test/responsetest.js index ef0a4f7..d69af3f 100644 --- a/test/responsetest.js +++ b/test/responsetest.js @@ -45,7 +45,7 @@ describe('Response headers', function() { it('pre-check poison', function() { const origCC = 'pre-check=0, post-check=0, no-cache, no-store, max-age=100, custom, foo=bar'; - const res = {headers:{'cache-control': origCC}}; + const res = {headers:{'cache-control': origCC, pragma: 'no-cache'}}; const cache = new CachePolicy(req, res, {ignoreCargoCult:true}); assert(!cache.stale()); assert(cache.storable()); @@ -61,6 +61,8 @@ describe('Response headers', function() { assert(/foo=bar/.test(cc)); assert.equal(res.headers['cache-control'], origCC); + assert(res.headers['pragma']); + assert(!cache.responseHeaders()['pragma']); }); it('cache with expires', function() {