Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
11 changes: 11 additions & 0 deletions test/responsetest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down