site/api-md: Prerender markdown routes at build time; enable Fluid compute - #1912
Open
marcleblanc2 wants to merge 1 commit into
Open
site/api-md: Prerender markdown routes at build time; enable Fluid compute#1912marcleblanc2 wants to merge 1 commit into
marcleblanc2 wants to merge 1 commit into
Conversation
Every doc page's markdown is now written as a static file during the build, so .md requests are served from the CDN instead of invoking a serverless function per request. Unknown slugs 404 without a function call (dynamicParams = false). vercel.json gains "fluid": true so the remaining functions (/api/og, the catch-all page renderer) share instances instead of cold-starting one per concurrent request. Amp-Thread-ID: https://ampcode.com/threads/T-01a08e2d-682f-75dd-a050-cb9bf8888dac Co-authored-by: Amp <amp@ampcode.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Vercel audit items 5a and 5b (see #1905,
dev/TODO.mditem 5). Stacked on #1901 because both editvercel.json; merge #1901 first, then retarget this tomain.What changes
/api/md/[...slug](serves<page>.md, which the middleware rewrites to this route):generateStaticParams()returns every post's slug, so Next writes each markdown response to disk duringnext build(.next/server/app/api/md/**/*.body). Vercel serves those from the CDN: no function invocation, no cold start.dynamicParams = falsemakes unknown slugs 404 at the edge without invoking a function. Behaviour change: an unknown.mdURL now gets the site's HTML 404 page (like any other unknown URL) instead of the plain-textNot Foundthe function used to return.index.mdxis skipped: its flattened path is empty and a catch-all needs at least one segment./api/mdwas never a valid URL for this route; the first build attempt failed on exactly that.vercel.json:"fluid": trueturns on Fluid compute for the remaining functions (/api/og/[...path], the[...slug]page renderer for non-prerendered paths). Fluid lets one instance handle many concurrent requests instead of one cold start per request, and bills active CPU time rather than wall-clock. Memory/CPU size still lives in the dashboard (Settings → Functions), not invercel.json.Verification (local)
pnpm build:/api/md/[...slug]shows as●(SSG) with ~500 paths; build time unchanged (about 40 s locally).pnpm start, then:/api/md/admin/config/site-config→ 200text/markdown, 47 902 B/api/md/cli/references/auth→ 200text/markdown, body starts with# src auth/api/md/does/not/exist→ 404Verification (after the preview deploys)
Compare against production for the same URL:
Expect the preview to answer with
x-vercel-cache: HIT(orPRERENDER) and a fastertime_totalon cold paths. For/api/og/..., expect similar or better latency under Fluid; nothing should be slower.