perf: serve header logo from hashed, CDN-cached static assets - #1979
Draft
marcleblanc2 wants to merge 1 commit into
Draft
marcleblanc2 wants to merge 1 commit into
marcleblanc2 wants to merge 1 commit into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
This comment has been minimized.
This comment has been minimized.
marcleblanc2
force-pushed
the
marc/perf/inline-logo
branch
from
September 17, 2026 02:32
1650043 to
a21e435
Compare
Import the two logo SVGs instead of serving them from public/, so they ship from /_next/static/media/ with a content hash and a one-year immutable Cache-Control header, and Cloudflare caches them like the rest of the static bundle. public/ files are served with max-age=0 and BYPASS the Cloudflare cache, costing two origin round-trips on every page load. The OG image route now reads the dark logo from src/images/. Amp-Thread-ID: https://ampcode.com/threads/T-01a0ac9d-704f-73fe-8211-1b3e5840969f Co-authored-by: Amp <amp@ampcode.com>
marcleblanc2
force-pushed
the
marc/perf/inline-logo
branch
from
September 17, 2026 10:20
a21e435 to
ce80d7a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The header logo is two
<img>tags (light and dark variants) served frompublic/. Vercel servespublic/files withCache-Control: public, max-age=0, so Cloudflare marks themcf-cache-status: BYPASSand every page load pays two origin round-trips (~155 ms each in the HAR of/docs/batch-changes/delete-a-batch-change)./docs/logo-theme-{light,dark}.svg/_next/static/media/logo-theme-{light,dark}.<hash>.svgCache-Controlpublic, max-age=0public, max-age=31536000, immutableBYPASSHIT(same path class as fonts and JS chunks)Fix
Move the two SVGs from
public/tosrc/images/and import them inLogo.tsxvianext/image. Webpack emits them into/_next/static/media/with a content hash and the one-year immutable header, the same as every other static asset. The component keeps the same two-<img>theme switch (dark:hidden/dark:block) andpriority, so there is no visual or LCP change.The OG image route (
src/app/api/og/[...path]/route.tsx) read the dark logo frompublic/at request time; it now reads fromsrc/images/.Verification
tsc --noEmit,pnpm lint,pnpm buildclean.next startrenderssrc="/_next/static/media/logo-theme-dark.8264a8f4.svg"andlogo-theme-light.d258bd04.svg, bothimage/svg+xmlwithCache-Control: public, max-age=31536000, immutable./api/og/...still returns 200image/png.Notes
public/asset referenced from the layout has the same problem; the same import pattern fixes it.