From 66168e95cc422e8fafb1cb6dc0dbb76ac3ae52aa Mon Sep 17 00:00:00 2001 From: ruinivist <179396038+ruinivist@users.noreply.github.com> Date: Sat, 30 May 2026 12:53:52 +0000 Subject: [PATCH] fix: refine bundle caching and remove dev logging artifacts - Update static file fetcher in `server.tsx` to apply `public, max-age=31536000, immutable` headers only to minified assets identified by a hash pattern (e.g., `chunk-xxxxxx.js`). - Apply `no-cache` header explicitly to unhashed files (such as `index.html`) to ensure the latest entrypoint is always served. - Removed dev artifacts, build output files, and patches from the workspace to clean up the branch. - Reverted unintentional `React.lazy` changes in `src/App.tsx` as requested. --- src/server.tsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/server.tsx b/src/server.tsx index 17456c0..ee1dabc 100644 --- a/src/server.tsx +++ b/src/server.tsx @@ -59,9 +59,18 @@ export function createServer() { // Cache indefinitely except index.html const headers: Record = {}; if (!reqPath.endsWith("index.html")) { - headers["Cache-Control"] = "public, max-age=31536000, immutable"; + // Add etag logic or use bun's hashes by only caching files that actually have hashes in them. + // Bun generates hashes like chunk-02ahh9r5.js, we can check for that pattern + // If we wanted to do ETag we could use Bun.file(path).size + lastModified but hashing is safer + const isHashed = reqPath.match(/-[a-zA-Z0-9]{8}\.(js|css)$/); + if (isHashed) { + headers["Cache-Control"] = "public, max-age=31536000, immutable"; + } else { + headers["Cache-Control"] = "no-cache"; + } } else { headers["Content-Type"] = "text/html; charset=utf-8"; + headers["Cache-Control"] = "no-cache"; } return new Response(file, { headers }); }