Skip to content

Commit 5c319a7

Browse files
Indicate in response headers when the cache was hit (#29)
Useful e.g. to adapt the rate-limiting behavior of a crawler
1 parent 2712aa0 commit 5c319a7

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

fetch-filecache.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,9 @@ async function cacheFetch(url, options) {
409409
return new Response(null, { url, status: 304, headers });
410410
}
411411
let readable = fs.createReadStream(cacheFilename);
412+
// Indicate this is coming from the cache via
413+
// https://www.rfc-editor.org/rfc/rfc9211.html
414+
headers["cache-status"] = "fetch-filecache-for-crawling; hit";
412415
return new Response(readable, { url, status, headers });
413416
}
414417

0 commit comments

Comments
 (0)