perf: optimize production assets and proxy-aware URLs
This commit is contained in:
@@ -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";
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user