Skip to content

Commit

Permalink
fix(static): send immediate empty responses for 304 handling (#1639)
Browse files Browse the repository at this point in the history
  • Loading branch information
markthree authored Aug 26, 2023
1 parent b1e676e commit 03f5963
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/runtime/static.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
setResponseHeader,
setResponseStatus,
removeResponseHeader,
send,
} from "h3";
import {
decodePath,
Expand Down Expand Up @@ -76,8 +75,7 @@ export default eventHandler((event) => {
const ifNotMatch = getRequestHeader(event, "if-none-match") === asset.etag;
if (ifNotMatch) {
setResponseStatus(event, 304, "Not Modified");
send(event, "");
return;
return "";
}

const ifModifiedSinceH = getRequestHeader(event, "if-modified-since");
Expand All @@ -88,8 +86,7 @@ export default eventHandler((event) => {
new Date(ifModifiedSinceH) >= mtimeDate
) {
setResponseStatus(event, 304, "Not Modified");
send(event, "");
return;
return "";
}

if (asset.type && !getResponseHeader(event, "Content-Type")) {
Expand Down

0 comments on commit 03f5963

Please sign in to comment.