Render Header and Footer statically instead of as server islands#747
Render Header and Footer statically instead of as server islands#747jamiefolsom wants to merge 2 commits into
Conversation
Their content only changes on CMS publish, so per-request island rendering buys nothing and costs two SSR round-trips per page view. Active-nav state now comes from the page's own pathname (passed down from Layout) instead of the Referer header, which also removes the island-without-Referer failure mode (#743) for these components and lets static builds render them at build time. HeaderContainer's client:load transparency wrapper is unchanged; content islands (posts, detail pages, home) are untouched.
✅ Deploy Preview for padp-staging ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for juel-staging ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for juel-ancestry ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for pss-scavenger-hunt ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for marronage-staging ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for relnet-staging ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for juel-life ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
I suppose before merging, in addition to resolving conflicts, I'd like to understand why some of the deploy previews (but not others) are just rendering blank pages (see the |
Closes #745. Draft — intended to land after #746 (the cache TTL/purge PR), whose CDN caching absorbs the cost of moving the navbar queries into the page render.
Header and Footer content (nav, translations, branding) only changes on CMS publish, but as server islands they cost two extra SSR round-trips per page view — 0.15–2.2 s each on cache misses in this week's measurements — and they fail entirely when an island request has no Referer header (#743), since that's where an island learns what page it's on.
Changes:
Layout.astro:server:deferremoved from Header and Footer; each receivespathname={Astro.url.pathname}.Header.astro/Footer.astro: active-nav state and the language picker use thepathnameprop instead of the Referer; their per-islandsetCacheControlcalls are gone (the page response, which now contains them, is already covered by Layout).getCurrentURLdeleted fromsrc/utils/url.ts— these were its only callers.Not touched:
HeaderContainer client:load(transparency wrapper), content islands (posts, paths, pages, detail pages, home).Why prop threading instead of client-side
location.pathname: NavBar renders on the server, and the CDN cache key is the URL, so every cached page carries its own correct active state — including underSTATIC_BUILD, where header/footer previously never resolved at all (islands need a server).Verified: vitest suite green; components compile in a static build (which then fails at a pre-existing, unrelated
getStaticPathscrash inapi/gallery/[manifestId].json.tswhen the config has no gallery — identical failure on develop; separate issue to follow). Render-level QA: deploy preview — check a custom-navbar site and a default-navbar site, active-nav highlighting, mobile header, and the language picker on a multi-locale site.