diff --git a/index.js b/index.js index bee995a..9577212 100644 --- a/index.js +++ b/index.js @@ -144,7 +144,7 @@ module.exports = class CachePolicy { // When the Cache-Control header field is not present in a request, caches MUST consider the no-cache request pragma-directive // as having the same effect as if "Cache-Control: no-cache" were present (see Section 5.2.1). if ( - !res.headers['cache-control'] && + res.headers['cache-control'] == null && /no-cache/.test(res.headers.pragma) ) { this._rescc['no-cache'] = true; diff --git a/test/responsetest.js b/test/responsetest.js index a3a98d9..c0d48b3 100644 --- a/test/responsetest.js +++ b/test/responsetest.js @@ -278,6 +278,17 @@ describe('Response headers', function() { assert(cache.stale()); }); + it('blank cache-control and pragma: no-cache', function() { + const cache = new CachePolicy(req, { + headers: { + 'cache-control': '', + pragma: 'no-cache', + 'last-modified': new Date().toGMTString(), + }, + }); + assert(!cache.stale()); + }); + it('no-store', function() { const cache = new CachePolicy(req, { headers: {