Skip to content

Commit

Permalink
fix: πŸ› Deliver etags also for home route
Browse files Browse the repository at this point in the history
  • Loading branch information
dkolba committed Jun 14, 2023
1 parent c8b8595 commit f4e205c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,12 +279,10 @@ export async function pathHandler({
mediaBaseUrl: resource,
});
const body = template(markup?.toString(), stylesheetlinks, css);
const etag = await calculate(body);

const headers = new Headers({
"content-type": "text/html",
});
etag && headers.append("etag", etag);
return { body, headers, status: 200 };
}

Expand All @@ -301,13 +299,17 @@ async function reply(
},
) {
const bodyEtag = await calculate(body);
console.log("bodyEtag : ", bodyEtag);
console.log("ifNoneMatch: ", ifNoneMatch);
if (`W/${bodyEtag}` === ifNoneMatch) {
return new Response(null, {
headers: headers,
status: 304,
});
}

const etag = await calculate(body);
etag && headers.append("etag", etag);
return new Response(body, {
headers: headers,
status,
Expand Down

0 comments on commit f4e205c

Please sign in to comment.