Set headers only on 304

This commit is contained in:
D. Berge
2025-08-11 22:06:51 +02:00
parent 48d9f45fe0
commit 301e5c0731

View File

@@ -23,9 +23,9 @@ function ifNoneMatch (req, res, next) {
if (cached) {
DEBUG("ETag match. Returning cached response (ETag: %s, If-None-Match: %s) for %s %s",
cached.etag, req.get("If-None-Match"), req.method, req.url);
setHeaders(res, cached.headers);
if (req.method == "GET" || req.method == "HEAD") {
res.status(304).send();
setHeaders(res, cached.headers);
res.status(304).end();
// No next()
} else if (!isIdempotentMethod(req.method)) {
res.status(412).send();