#3524·vinext

cdnAdapter: every uncacheable request costs two Worker invocations (gateway + `VinextUncachedResponse`)

Author: srousseyCreated Sep 28, 2026Updated Sep 28, 2026

With cache: { cdn: cdnAdapter() }, every request runs as two Worker invocations: the default gateway, then a ctx.exports call to VinextCachedResponse or VinextUncachedResponse. That second hop makes sense for the shared stage, because Workers Cache sits in front of VinextCachedResponse. For bypass renders it adds a whole invocation and its CPU without caching anything. In an app that is mostly signed-in, dynamic pages, that is nearly every request.

What we measured

wrangler tail --format json on a production deploy shows two events for each browser request. Both carry the same cf-ray, and the second has "entrypoint": "VinextUncachedResponse":

invocation entrypoint CPU wall
gateway (request stage) default ~7–9 ms ~300–450 ms
render (response stage) VinextUncachedResponse ~30–40 ms ~250–350 ms

So each dynamic request costs ~7–9 ms of CPU and one extra invocation before rendering starts. RSC link prefetches pay it too. One page view in our dashboard triggered about 150 prefetches in 15 seconds, which came to about 300 invocations. On a CPU-constrained plan we then got Worker exceeded CPU time limit (Cloudflare error 1101) on requests that each used 4–21 ms of CPU, because the kill takes every request in the isolate with it.

Where it happens

dist/cache/cdn-adapter.worker.js, in the gateway's dispatchResponseStage. It picks an export by options.cache and always calls it through binding.fetch(...):

javascript
const usesSharedCache = options.cache === "shared";
// ...
const binding = getResponseStageBinding(stageContext, usesSharedCache ? CACHED_RESPONSE_STAGE_EXPORT : UNCACHED_RESPONSE_STAGE_EXPORT, serializedInvocation);

What we tried locally

Rendering bypass requests in the gateway works functionally. We added one line before the try:

javascript
if (!usesSharedCache) return invokeResponseStage(stageRequest, env, stageContext, invocation);

Under wrangler dev on the built output, dynamic routes then rendered in one invocation. The prerendered, cacheable routes still went through VinextCachedResponse with their __vinext_cache_key.

In #3305 a maintainer said the entrypoint separation "is necessary for security reasons", so we don't assume this patch is safe to ship.

Ask

  1. What is the security property the separate VinextUncachedResponse entrypoint provides for bypass renders? Knowing that would tell users whether the extra invocation is avoidable in their app.
  2. If bypass renders can safely run in the gateway, could that be the default, or an option on cdnAdapter()? For example cdnAdapter({ inlineBypass: true }), or a per-route opt-out for routes that are dynamic by construction.
  3. If not, a note in the docs about the cost: two invocations per uncacheable request, including prefetches, and roughly 7–9 ms of extra CPU each in our measurements. It matters for anyone near the Workers CPU or request limits.

Environment

vinext 1.0.0-beta.10, @vinext/cloudflare 1.0.0-beta.8, @cloudflare/vite-plugin ^1.56, wrangler 4.135, compatibility_date 2026-07-17 with nodejs_compat. Config: vinext({ cache: { data: kvDataAdapter(), cdn: cdnAdapter() } }). Reproduced in production and under wrangler dev on the built output.

Related: #3305, the same staged-entrypoint change seen from the per-request-scope side.