Skip to content

Commit b935c91

Browse files
fix(cache): return immutable staleAt in milliseconds (#5048)
1 parent 8d1e8d9 commit b935c91

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

lib/handler/cache-handler.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ function determineStaleAt (cacheType, now, age, resHeaders, responseDate, cacheC
479479

480480
if (cacheControlDirectives.immutable) {
481481
// https://www.rfc-editor.org/rfc/rfc8246.html#section-2.2
482-
return 31536000
482+
return 31536000000
483483
}
484484

485485
return undefined

test/interceptors/cache.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2132,6 +2132,8 @@ describe('Cache Interceptor', () => {
21322132
const oneYear = 31536000000
21332133
// deleteAt should be approximately 1 year out
21342134
equal(cached.deleteAt >= clock.now + oneYear - 1000, true, `deleteAt (${cached.deleteAt}) should be ~1 year out`)
2135+
// staleAt should also be approximately 1 year out (not ~8.7 hours)
2136+
equal(cached.staleAt >= clock.now + oneYear - 1000, true, `staleAt (${cached.staleAt}) should be ~1 year out`)
21352137
})
21362138

21372139
test('stale-while-revalidate extends deleteAt beyond staleAt', async () => {

0 commit comments

Comments
 (0)