VercelDev & Eng

Content type: Concept

4 min read

Vercel CDN gets cache bypass rules controlled by frameworks

Article · Dev & Eng
Reading
4 min
Tables
1
Code
1
In short

Vercel has opened up, via the Build Output API, a mechanism that lets frameworks define when to bypass edge cache based on request and response headers. Next.js 16.5 already uses this to stop reloading entire pages every time a bot like Bingbot crawls them.

The problem: bots that need the complete <head>

Next.js uses Partial Prerendering to serve a static shell right away and fill in the rest asynchronously. This works well for browsers, which wait for streaming to finish, but bots like Bingbot, Discordbot, Slackbot, Twitterbot and WhatsApp's crawler don't have that patience: they read the HTML once and need to find title, description and Open Graph tags already in place inside the <head>.

If the cached page doesn't have that complete metadata by the time the bot crawls it, the link preview comes out broken, with no title or image. Next.js's previous solution was blunt: any request whose user-agent matched the list of these bots would bypass the cache entirely and trigger the rendering function, even when the cached version already had everything the bot needed.

How afterCacheBypass works

Vercel exposed this control in the Build Output API, the format any framework uses to generate a deployment with Vercel Functions, routing and cache. The .vercel/output/config.json file now accepts an afterCacheBypass list, with named rules and conditions combined via hasAll:

Example of the .vercel/output/config.json file showing the afterCacheBypass rule that bypasses cache for HTML-limited bots when the page is missing metadata
Example of the .vercel/output/config.json file showing the afterCacheBypass rule that bypasses cache for HTML-limited bots when the page is missing metadata. Reprodução: vercel.com.
json
{
 "version": 3,
 "afterCacheBypass": [
 {
 "name": "HTML Limited Bots",
 "hasAll": [
 {
 "type": "request.header",
 "key": "user-agent",
 "value": { "re": "Bingbot|Discordbot|Slackbot|Twitterbot|WhatsApp" }
 },
 {
 "type": "cache.response.header",
 "key": "x-has-head-metadata",
 "value": { "eq": "0" }
 }
 ]
 }
 ]
}

Each condition can look at a request header (request.header) or at a header already present in the cached response (cache.response.header), comparing by equality (eq) or regex (re). Rules are evaluated in order, and the first one that matches decides the fate of the request.

Expert views

What people are saying about it.

Since December 3, 2026, it has been possible to create repositories on GitHub using SHA-256 instead of SHA-1. The algorithm has existed in Git since 2020, but it's only now arriving on github.com, with no conversion for existing repositories.

Bisneto Bragain an iMasters article · Read the article: GitHub Enables Creation of Git Repositories with SHA-256 in Public Preview

A test published on Planet PostgreSQL shows that REPACK (CONCURRENTLY) allows reading and writing during most of a table's reorganization. But there is a final moment when the lock returns, and it can take longer than it seems.

Roberto Dinizin an iMasters article · Read the article: PostgreSQL 19: REPACK (CONCURRENTLY) shrinks tables without blocking reads, but locks at the end

Vercel checks the rules in order. If a rule matches, Vercel bypasses the cache and invokes the function, and the response is served with x-vercel-cache: BYPASS. If no rule matches, Vercel serves the cached page.

Vercel Changelog

An important scope detail: these rules only apply to static prerendered pages. API routes and pages rendered server-side on every request don't fall under this logic, because there's no page cache for them to begin with.

What Next.js 16.5 does with this

Next.js now marks every cached page with its own header, x-has-head-metadata, indicating whether the <head> was already complete in that snapshot. The rule combines both conditions with hasAll: it only triggers the bypass when the user-agent belongs to an HTML-limited bot and that header shows missing metadata (eq: "0").

In practice, this flips the previous logic. Instead of bypassing whenever the visitor is a bot, Next.js 16.5 only bypasses when the cache genuinely doesn't serve that bot's needs. According to Vercel, on nextjs.org itself more than 70% of these bot requests now result in a cache hit, rather than a new render.

For those already running Next.js on Vercel, there's nothing to configure: the rule is emitted automatically by the framework's build, and the gain comes simply from updating the version. It's a rare case of infrastructure optimization that arrives with no visible trade-off for the application developer.

Why this matters for those building with Next.js

  • Fewer function invocations: every avoided bypass is a Vercel Function that doesn't need to run, which weighs directly on the bill for anyone with meaningful crawler traffic.
  • Lower latency for whoever consumes the preview: social networks and indexing tools get a cached response, not the time it takes for a full render.
  • A fix without reloading everything: the original problem (incomplete metadata for bots) stays solved, just selectively instead of bluntly.

For those building frameworks or using the Build Output API directly

Next.js is the first to use afterCacheBypass, but the rule is a platform primitive, not something exclusive to it. Any framework or build tool that generates Vercel's format can write its own rules in config.json, combining request headers with headers the framework itself writes into the cached response.

This opens room for cases beyond bots: cookie-based personalization, A/B test variants signaled by a header, or localization when the cached content doesn't cover all expected languages. None of this is documented as an official use case yet, but the mechanism is generic enough to support these ideas.

What's left out

Three limits are worth weighing before celebrating the feature as a general cache solution:

LimitPractical consequence
Only applies to prerendered pagesAPI routes and per-request SSR don't gain this control
It's a Vercel mechanism via the Build Output APIThere's no equivalent when running Next.js in standalone mode outside Vercel
Depends on the framework marking headers correctlyA bug when writing x-has-head-metadata serves a bot incomplete metadata with no visible error

The gain is real and narrowly scoped: it solves, with surgical precision, a problem that previously forced a blunt bypass. But it's also one more reason to measure, using the x-vercel-cache header on responses, whether your application's cache behavior is coming out as expected before assuming the update solved everything on its own.

Translated from the Brazilian Portuguese original · Read the original

Read also
Dev & Eng

AI SDK 7.1 brings AI agent control into the front-end app

Vercel's AI SDK update moves controls into the front-end that used to live only in the backend: correcting a running agent, recovering from an error mid-stream, and tracing a workflow that spans multiple processes in a single trace.

Carina Ferreira··1 min