perf: cache un-hashed static assets under /img and /logo - #475
Conversation
These are served from public/ with `public, max-age=0, must-revalidate`, so every navigation pays a conditional-request round-trip for them. The responses do return 304 with 0 bytes, so this was never a re-download problem — just a latency one, which is why it's a modest win rather than a large one. `immutable` is not safe here: the filenames are not content-hashed, so a redeploy has to be able to replace them in place. An hour of freshness plus a week of stale-while-revalidate drops the round-trip while bounding how long a replaced asset can linger. Extends headers() to apply in prod, which previously returned no rules at all; the noindex rule stays non-prod only. Tests updated to match. Refs #471
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Claude finished @alukach's task in 4m 38s —— View job Review of PR #475
❌ Changes requested — see findings below.
Everything else checks out:
Note: I wasn't able to run |
Part of #471.
What
Adds a
Cache-Controlrule for/img/*and/logo/*innext.config.js, and makesheaders()apply in prod (it previously returned no rules at all there). The noindex rule stays non-prod only.Why
These assets are currently served
public, max-age=0, must-revalidate, so every navigation pays a conditional-request round-trip for each one.Calibrating the win honestly: I verified the revalidation returns
304with 0 bytes, so this was never a re-download problem — just latency. It's a modest fix, not a headline one, and it's the smallest item in #471.Why not
immutableThe filenames under
public/are not content-hashed, soimmutablewould be actively dangerous — a redeploy could never replace them for anyone holding a cached copy. That's not hypothetical: #473 changes the bytes ofclouds.pngat the same filename.An hour of freshness removes the round-trip while bounding how long a replaced asset can linger, and
stale-while-revalidatekeeps the refresh off the critical path. Content-hashing these filenames would unlock a realimmutablepolicy later; noted in #471.Verification
npx jest next.config.test.ts— 4 passed. I updated the three existing tests (the prod case asserted[], which no longer holds) and added one asserting the cache rule applies in every stage.🤖 Generated with Claude Code