Skip to content

perf(build): deduplicate static blog Markdown parsing across pages - #92

Merged
yotamon merged 2 commits into
mainfrom
perf/cache-static-blog-markdown-20261016
Oct 16, 2026
Merged

yotamon merged 2 commits into
mainfrom
perf/cache-static-blog-markdown-20261016

Conversation

@yotamon

@yotamon yotamon commented Oct 16, 2026

Copy link
Copy Markdown
Collaborator

Why

Vercel is prerendering 204 static pages using one worker. The public blog has 36 Markdown posts (each with English/Hebrew content). getAllPosts() and getPostBySlug() reread and remark-render full Markdown during each call, including calls from the homepage, sitemap, blog listing, and each prerendered article's page+metadata.

What changed

  • Memoize parsed published posts by slug only in production, reusing concurrent promises. Restrict the post cache to known published slugs to prevent unbounded growth from requests for invalid slugs.
  • Memoize the sorted list of all posts in production so static generation does not reread all 36 files on every call.
  • Preserve uncached reads during development to keep live Markdown editing responsive.
  • Cover production identity/parallel behavior, development re-reading, and missing post results.

Safety

  • The Markdown files ship with the deployment and cannot change in a running production instance without a new release.
  • No changes to route behavior, locale content, metadata, SEO, rendering semantics, or runtime API.
  • No Vercel preview and no manual deployment; compare static-generation timings on the next automatic production deployment after merging.

@yotamon
yotamon merged commit 7801c26 into main Oct 16, 2026
2 checks passed
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