perf: optimize production assets and proxy-aware URLs

This commit is contained in:
2026-07-12 17:27:02 +05:30
parent 935b3103dd
commit 6dfef7da3c
58 changed files with 118 additions and 90 deletions
+3
View File
@@ -33,6 +33,9 @@ function cachePolicy(filePath: string, mode: Mode): string {
if (mode !== "production") return "no-cache";
const name = filePath.split(/[\\/]/).pop() ?? "";
if (/\.html?$/i.test(name)) return REVALIDATE_CACHE;
// Font URLs are content assets with expensive transfer costs and are almost
// always renamed when changed. Cache them like fingerprinted build assets.
if (/\.(?:woff2?|ttf|otf|eot)$/i.test(name)) return IMMUTABLE_CACHE;
return /(?:^|[.-])[a-f0-9]{8,}(?:[.-]|$)/i.test(name) ? IMMUTABLE_CACHE : "public, max-age=3600";
}