ETag plus If-None-Match turns a repeat fetch into a 304
A client that already has the response should not download it again. Send a hash of the body as an ETag. The client sends it back and you answer 304 with no body when nothing changed.
const etag = `"${hash(body)}"`;
if (req.headers.get("if-none-match") === etag) return new Response(null, { status: 304 });
return new Response(body, { headers: { ETag: etag, "Cache-Control": "no-cache" } });no-cache means "always revalidate", which is exactly what makes the 304 path fire.
httpcaching