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

Commit

Permalink
feat(cache): add special headers when request was loaded straight fro…
Browse files Browse the repository at this point in the history
…m cache
  • Loading branch information
zkat committed Apr 4, 2017
1 parent a021a6b commit 8a7dbd1
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,13 @@ module.exports = class Cache {
cacheIntegrity: info.integrity,
integrity: opts && opts.integrity
})) {
const resHeaders = new fetch.Headers(info.metadata.resHeaders)
resHeaders.set('X-LOCAL-CACHE', this._path)
resHeaders.set('X-LOCAL-CACHE-TIME', new Date(info.time).toUTCString())
if (req.method === 'HEAD') {
return new fetch.Response(null, {
url: req.url,
headers: info.metadata.resHeaders,
headers: resHeaders,
status: 200
})
}
Expand Down Expand Up @@ -94,7 +97,7 @@ module.exports = class Cache {
body.write('dummy')
return new fetch.Response(body, {
url: req.url,
headers: info.metadata.resHeaders,
headers: resHeaders,
status: 200,
size: stat.size
})
Expand Down

0 comments on commit 8a7dbd1

Please sign in to comment.