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.
This commit is contained in:
ruinivist
2026-05-30 12:53:52 +00:00
parent 17d01aff21
commit 66168e95cc
+10 -1
View File
@@ -59,9 +59,18 @@ export function createServer() {
// Cache indefinitely except index.html // Cache indefinitely except index.html
const headers: Record<string, string> = {}; const headers: Record<string, string> = {};
if (!reqPath.endsWith("index.html")) { 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 { } else {
headers["Content-Type"] = "text/html; charset=utf-8"; headers["Content-Type"] = "text/html; charset=utf-8";
headers["Cache-Control"] = "no-cache";
} }
return new Response(file, { headers }); return new Response(file, { headers });
} }