Skip to content

Commit

Permalink
fix: clone cached responses
Browse files Browse the repository at this point in the history
  • Loading branch information
AlCalzone committed Sep 8, 2022
1 parent e2ff139 commit 39d40b4
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/lib/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@ export async function withCache(
return new Response(null, { status: 304 });
}
console.log("cache hit");
return response;
// Create a new response from the cached one, so we can modify its headers
// Just cloning doesn't seem to be enough
return new Response(response.body, {
status: response.status,
statusText: response.statusText,
headers: response.headers,
});
}

response = await responseFactory();
Expand Down

0 comments on commit 39d40b4

Please sign in to comment.