Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@ export function cache(): Middleware {
const response = await cache.match(req);

if (response) {
// headers are immutable, so we need to clone the headers
// to add the Accept-Ranges header for range requests
const headers = new Headers(response.headers);
headers.set("Accept-Ranges", "bytes");

if (c.req.header("If-None-Match") === response.headers.get("ETag")) {
return new Response(null, {
status: 304,
statusText: "Not Modified",
headers: response.headers,
headers,
});
}

// headers are immutable, so we need to clone the headers
// to add the Accept-Ranges header for range requests
const headers = new Headers(response.headers);
headers.set("Accept-Ranges", "bytes");

return new Response(response.body, {
status: response.status,
statusText: response.statusText,
Expand Down
Loading