Setting the file. One moment.
Subchapter 7.7
references/playbooks/api-service.mdMarkdown2 KBView on GitHub
Headless API backend. No UI routes. Often consumed by mobile apps, partner integrations, or other Vercel projects via rewrites.
Function Duration dominates (every request is a function invocation). Edge Requests scale with API traffic. External API costs matter when the service is a thin shim over third-party APIs (Stripe, Twilio, etc.).
Cache-Control: public, s-maxage=<seconds>, stale-while-revalidate=<longer>. The CDN serves repeat callers without invoking the function.Promise.all is the obvious fix.after() (Next 15+) for analytics, webhooks-to-self, and any write that doesn’t affect the response.Cache-Control on the public GETs. This is the most common finding in this profile, and the easiest fix.await checkAuth() then await loadData() — these are often independent and can run in parallel if your auth path doesn’t depend on the data.after().https://vercel.com/docs/caching/cdn-cache — the GET-handler Cache-Control fixvercel-react-best-practices:async-parallel — parallelize external API callsvercel-react-best-practices:server-after-nonblocking — after() for post-response workhttps://vercel.com/docs/fluid-compute — when cold starts on infrequently-called endpoints hurthttps://nextjs.org/docs/app/building-your-application/routing/middleware — for rate-limit middleware