Skip to content

Commit 7a9f9e1

Browse files
committed
Test + comments
1 parent 612aaff commit 7a9f9e1

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,13 @@ module.exports = class CachePolicy {
260260
return isFinite(ageValue) ? ageValue : 0;
261261
}
262262

263+
/**
264+
* Value of applicable max-age (or heuristic equivalent) in seconds. This counts since response's `Date`.
265+
*
266+
* For an up-to-date value, see `timeToLive()`.
267+
*
268+
* @return Number
269+
*/
263270
maxAge() {
264271
if (!this.storable() || this._rescc['no-cache']) {
265272
return 0;

test/responsetest.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ describe('Response headers', function() {
3434
assert.equal(cache.maxAge(), 678);
3535
});
3636

37+
it('IIS', function() {
38+
const cache = new CachePolicy(req, {headers:{'cache-control': 'private, public, max-age=259200'}}, {shared:false});
39+
assert(!cache.stale());
40+
assert.equal(cache.maxAge(), 259200);
41+
});
42+
3743
it('pre-check tolerated', function() {
3844
const cc = 'pre-check=0, post-check=0, no-store, no-cache, max-age=100';
3945
const cache = new CachePolicy(req, {headers:{'cache-control': cc}});

0 commit comments

Comments
 (0)