perf(web): pin /home/* assets to 1y immutable cache
Next.js serves /public files with `Cache-Control: public, max-age=0, must-revalidate`, so the home covers + first-act JSON were re-fetched on every visit. Verified against 30 days of Vercel metrics: /home/* alone was ~62% of Fast Data Transfer egress (5.42 GB) while the files total only ~31 MB — the same bytes re-downloaded hundreds of times. Add a headers() rule scoping `public, max-age=31536000, immutable` to /home/:path* only; other paths keep their defaults (verified /icon.svg still returns no-cache). Filenames under /home are stable (covers fN/mN.webp, first-act JSON by card name), so immutable is safe; if a first-act JSON is ever re-baked under the same name, bump a query string or purge the cache. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -6,6 +6,17 @@ const config: NextConfig = {
|
||||
turbopack: {
|
||||
root: __dirname,
|
||||
},
|
||||
// /public defaults to `max-age=0, must-revalidate`; pin the stable /home/* covers + first-act JSON for 1y so browsers/CDN stop re-downloading them.
|
||||
async headers() {
|
||||
return [
|
||||
{
|
||||
source: "/home/:path*",
|
||||
headers: [
|
||||
{ key: "Cache-Control", value: "public, max-age=31536000, immutable" },
|
||||
],
|
||||
},
|
||||
];
|
||||
},
|
||||
};
|
||||
|
||||
export default config;
|
||||
|
||||
Reference in New Issue
Block a user