Browse Source

When forcing cacheability, drop pragma:no-cache too

master v3.3.2
Kornel Lesiński 8 years ago
parent
commit
ed1b3f38f4
  1. 1
      index.js
  2. 2
      package.json
  3. 4
      test/responsetest.js

1
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

2
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",

4
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() {

Loading…
Cancel
Save