Skip to content

perf(api): serve stale sitemap XML while refreshing#968

Merged
raymondjacobson merged 1 commit into
mainfrom
codex/sitemap-stale-revalidate
Jun 22, 2026
Merged

perf(api): serve stale sitemap XML while refreshing#968
raymondjacobson merged 1 commit into
mainfrom
codex/sitemap-stale-revalidate

Conversation

@raymondjacobson

Copy link
Copy Markdown
Member

Summary

  • extend the sitemap XML cache to cover both /sitemaps/:type/index.xml and /sitemaps/:type/:fileName
  • serve stale sitemap XML immediately while refreshing expired entries in the background
  • keep the last good sitemap XML when background refresh fails
  • add sitemap success cache headers with stale-while-revalidate / stale-if-error, and mark sitemap errors no-store

Context

Recent prod failures on /sitemaps/track/index.xml and track page sitemaps were cold dynamic DB reads getting canceled by Postgres hot-standby recovery conflicts (SQLSTATE 40001). The prior cache only covered page XML; index XML still had to rebuild on request. This keeps both index and page XML available from the last successful generation while refreshes happen asynchronously.

Test Plan

  • go test ./api -run TestSitemap -count=1
  • go test ./api -run ^$
  • git diff --check

@raymondjacobson raymondjacobson merged commit dbb04d9 into main Jun 22, 2026
5 checks passed
@raymondjacobson raymondjacobson deleted the codex/sitemap-stale-revalidate branch June 22, 2026 23:36
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.

1 participant