all repos — homestead @ 7575406976387391172f12acf019c8e8ad3b09ef

Code for my website

allow 404 errors to be cached

Alan Pearce
commit

7575406976387391172f12acf019c8e8ad3b09ef

parent

90029fa86a8daeec421464720b2b7b216db52f59

1 file changed, 2 insertions(+), 6 deletions(-)

jump to
M src/app.tssrc/app.ts
@@ -34,7 +34,6 @@ type File = {
filename: string; handle: BunFile; relPath: string; - headers?: Record<string, string>; type: string; size: number; mtime: Date;
@@ -80,10 +79,6 @@ filename,
relPath: "/" + path, handle: handle, type: pathname.startsWith("/feed-styles.xsl") ? "text/xsl" : handle.type, - headers: - pathname === "/404.html" - ? Object.assign({}, defaultHeaders, { "cache-control": "no-cache" }) - : undefined, size: stat.size, mtime: stat.mtime, etag: `W/"${await hashFile(handle)}"`,
@@ -116,7 +111,7 @@ return new Response(await file.handle.arrayBuffer(), {
headers: { "last-modified": file.mtime.toUTCString(), ...extraHeaders, - ...(file.headers || defaultHeaders), + ...defaultHeaders, }, status: statusCode, });
@@ -238,6 +233,7 @@ const notfound = files.get("/404.html");
if (!request.headers.get("accept")?.split(",").includes("text/html")) { return new Response("404 Not Found", { status, + headers: defaultHeaders, }); } if (notfound) {