fix(marketing): prerender the sitemap again
Why
Since #8101 the production sitemap is rendered on every request (ƒ /sitemap.xml in the build log, CDN miss on every fetch). Before, it was a static file refreshed on an interval.
Cause
The sitemap reads the mobile-launch flag through unstable_cache. With cacheComponents on, the PostHog request inside it ends a route handler's prerender, so Next marks the route dynamic. It only happens when the PostHog host is reachable, which is why my local builds with a placeholder host stayed static.
What changes
getSiteFlag is a "use cache" function with the same one-minute lifetime. A failed read still returns false.
Verified locally
- With a real PostHog host:
ƒ /sitemap.xmlbefore the change,○ /sitemap.xml 1mafter. - Served build: the sitemap is a cache hit with 3,028 URLs including profiles; pricing, a non-English page,
/mobile, a profile and a 404 behave as before. - With the API unreachable at build, the build passes and the sitemap is static without profile URLs until its next refresh.
- Typecheck and the marketing tests pass.
Not verified
- The production build log and the live
x-vercel-cacheheader, which only exist after merge.
Summary by cubic
Restores prerendering for the production sitemap, which has been rendered on every request since cacheComponents was enabled. The feature-flag read went through unstable_cache, and the PostHog call inside it ended the route handler's prerender, so Next marked the route dynamic.
getSiteFlag is now a "use cache" function with the same one-minute lifetime, and a failed read still returns false. The sitemap is static again with a one-minute refresh.
Verified locally with a reachable PostHog host (ƒ /sitemap.xml before, ○ /sitemap.xml 1m after) and with the API unreachable at build (static, no profile URLs until refresh). Production build log and live x-vercel-cache header can only be checked after merge.
Summary by CodeRabbit
- Bug Fixes
- Site flags continue to refresh every 60 seconds, and flag evaluation failures continue to return
false.
- Site flags continue to refresh every 60 seconds, and flag evaluation failures continue to return