Skip to content
This repository has been archived by the owner on Jun 12, 2022. It is now read-only.

Commit

Permalink
fix(staleness): responses older than 8h were never stale :<
Browse files Browse the repository at this point in the history
  • Loading branch information
zkat committed Apr 18, 2017
1 parent 2e4f6bb commit b54dd75
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,13 @@ function isStale (req, res) {
method: req.method,
headers: adaptHeaders(req.headers)
}
const bool = !makePolicy(req, res).satisfiesWithoutRevalidation(_req)
const policy = makePolicy(req, res)
policy._responseTime = new Date(
res.headers.get('x-local-cache-time') ||
res.headers.get('date') ||
0 // better to pretend everything is stale
)
const bool = !policy.satisfiesWithoutRevalidation(_req)
return bool
}

Expand Down

0 comments on commit b54dd75

Please sign in to comment.