Skip to content

Render Header and Footer statically instead of as server islands#747

Open
jamiefolsom wants to merge 2 commits into
developfrom
feat/static-header-footer
Open

Render Header and Footer statically instead of as server islands#747
jamiefolsom wants to merge 2 commits into
developfrom
feat/static-header-footer

Conversation

@jamiefolsom

Copy link
Copy Markdown
Member

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:defer removed from Header and Footer; each receives pathname={Astro.url.pathname}.
  • Header.astro / Footer.astro: active-nav state and the language picker use the pathname prop instead of the Referer; their per-island setCacheControl calls are gone (the page response, which now contains them, is already covered by Layout).
  • getCurrentURL deleted from src/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 under STATIC_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 getStaticPaths crash in api/gallery/[manifestId].json.ts when 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.

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.
@netlify

netlify Bot commented Jul 13, 2026

Copy link
Copy Markdown

Deploy Preview for padp-staging ready!

Name Link
🔨 Latest commit 6242fbd
🔍 Latest deploy log https://app.netlify.com/projects/padp-staging/deploys/6a554c14f2fcbc00083851c5
😎 Deploy Preview https://deploy-preview-747--padp-staging.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented Jul 13, 2026

Copy link
Copy Markdown

Deploy Preview for juel-staging ready!

Name Link
🔨 Latest commit 6242fbd
🔍 Latest deploy log https://app.netlify.com/projects/juel-staging/deploys/6a554c15121b750009f4240e
😎 Deploy Preview https://deploy-preview-747--juel-staging.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented Jul 13, 2026

Copy link
Copy Markdown

Deploy Preview for juel-ancestry ready!

Name Link
🔨 Latest commit 6242fbd
🔍 Latest deploy log https://app.netlify.com/projects/juel-ancestry/deploys/6a554c15f0190e000891d191
😎 Deploy Preview https://deploy-preview-747--juel-ancestry.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented Jul 13, 2026

Copy link
Copy Markdown

Deploy Preview for pss-scavenger-hunt ready!

Name Link
🔨 Latest commit 6242fbd
🔍 Latest deploy log https://app.netlify.com/projects/pss-scavenger-hunt/deploys/6a554c1411e63a00080bfc6d
😎 Deploy Preview https://deploy-preview-747--pss-scavenger-hunt.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented Jul 13, 2026

Copy link
Copy Markdown

Deploy Preview for marronage-staging ready!

Name Link
🔨 Latest commit 6242fbd
🔍 Latest deploy log https://app.netlify.com/projects/marronage-staging/deploys/6a554c15fa386b0008fc04b7
😎 Deploy Preview https://deploy-preview-747--marronage-staging.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented Jul 13, 2026

Copy link
Copy Markdown

Deploy Preview for relnet-staging ready!

Name Link
🔨 Latest commit 6242fbd
🔍 Latest deploy log https://app.netlify.com/projects/relnet-staging/deploys/6a554c15948fb00008327783
😎 Deploy Preview https://deploy-preview-747--relnet-staging.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented Jul 13, 2026

Copy link
Copy Markdown

Deploy Preview for juel-life ready!

Name Link
🔨 Latest commit 6242fbd
🔍 Latest deploy log https://app.netlify.com/projects/juel-life/deploys/6a554c15c77d5100085eab5c
😎 Deploy Preview https://deploy-preview-747--juel-life.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@jamiefolsom
jamiefolsom requested a review from ajolipa July 14, 2026 17:17
@jamiefolsom
jamiefolsom marked this pull request as ready for review July 14, 2026 17:17

@ajolipa ajolipa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great to me.

@ajolipa

ajolipa commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

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 juel-staging and juel-ancestry previews, possibly among others). It might be unrelated to this PR specifically but I just want to know for sure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Header and Footer are server islands, but their content only changes on publish

2 participants