Skip to content

Commit

Permalink
Add cache header (#11)
Browse files Browse the repository at this point in the history
* 👍 add cache hit header

* 👍 add version doc
  • Loading branch information
naporin0624 authored Aug 10, 2023
1 parent 8c166da commit 26788c8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/honest-socks-thank.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@napolab/kv-response-cache": minor
---

add x-kv-cache header
6 changes: 5 additions & 1 deletion src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ export const kvCaches =

const key = new URL(c.req.url).pathname;
const response = await cache.match(key);
if (response) return response;
if (response) {
response.headers.set("X-KV-CACHE", "hit");

return response;
}

await next();

Expand Down

0 comments on commit 26788c8

Please sign in to comment.