From 8a7dbd11d0259ed9bb4046ab82481042fde8714b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kat=20March=C3=A1n?= Date: Mon, 3 Apr 2017 21:09:23 -0700 Subject: [PATCH] feat(cache): add special headers when request was loaded straight from cache --- cache.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cache.js b/cache.js index abcd72c..d18d593 100644 --- a/cache.js +++ b/cache.js @@ -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 }) } @@ -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 })