Skip to content

Commit

Permalink
fix: dont modify immutable headers (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
MoLow authored Sep 27, 2023
1 parent 6a94069 commit ed01248
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/handlers/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ const getHandler: Handler = async (request, env, ctx, cache) => {
const response = await cache.match(request);

if (typeof response !== 'undefined') {
response.headers.append('x-cache-status', 'hit');

return response;
}
}
Expand Down Expand Up @@ -51,7 +49,9 @@ const getHandler: Handler = async (request, env, ctx, cache) => {

// Cache response if cache is enabled
if (shouldServeCache && response.status !== 304 && response.status !== 206) {
ctx.waitUntil(cache.put(request, response.clone()));
const cached = response.clone();
cached.headers.append('x-cache-status', 'hit');
ctx.waitUntil(cache.put(request, cached));
}

response.headers.append('x-cache-status', 'miss');
Expand Down

0 comments on commit ed01248

Please sign in to comment.