From cba1d159254df9123c1faca8de31077f27702942 Mon Sep 17 00:00:00 2001 From: "vercel-gh-bot-2[bot]" <282331341+vercel-gh-bot-2[bot]@users.noreply.github.com> Date: Thu, 26 Nov 2026 09:45:31 +0000 Subject: [PATCH 1/2] [skills] Sync cdn-caching with current docs --- skills/cdn-caching/SKILL.md | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/skills/cdn-caching/SKILL.md b/skills/cdn-caching/SKILL.md index 7c449a55..a9623b24 100644 --- a/skills/cdn-caching/SKILL.md +++ b/skills/cdn-caching/SKILL.md @@ -109,7 +109,7 @@ Vercel caches at multiple layers between the visitor and your backend. A request | `REVALIDATED` | Foreground revalidation after a delete (or `Pragma: no-cache`) | | `BYPASS` | Caching skipped (`no-store`, `private`, cookies, etc.) | -- **Cache reason** (`cacheReason`) — the finer _explanation_ of that outcome for a single request. The `cache_result` metric lumps all `MISS`es (and all `STALE`s) together; the reason is the only thing that tells them apart. Eleven values: four for MISS, three map to BYPASS, three for STALE, one for REVALIDATED: +- **Cache reason** (`cacheReason`) — the finer _explanation_ of that outcome for a single request. The `cacheResult` metric lumps all `MISS`es (and all `STALE`s) together; the reason is the only thing that tells them apart. Eleven values: four for MISS, three map to BYPASS, three for STALE, one for REVALIDATED: | `cacheReason` | Refines | Meaning | | --------------------- | -------- | ----------------------------------------------------------------------------- | @@ -125,7 +125,7 @@ Vercel caches at multiple layers between the visitor and your backend. A request | `stale_error` | STALE | A revalidation attempt **failed**; serving the last-good copy (a bug signal) | | Tag-based deletion | REVALIDATED | Tag deleted (`dangerouslyDeleteByTag` / `revalidateTag(tag)` with no profile / dashboard purge by tag); foreground regen | - A raw `MISS` with reason `draft_mode` / `prerender_bypass` / `crawler` is **displayed as `BYPASS`** (all usually expected). The three `stale_*` reasons separate a healthy time refresh (`stale_time`) from a broad-tag blast (`stale_tag`) from a failing regen (`stale_error`). Read `cacheReason` from the dashboard Logs "Reason" row, find matching requests with `vercel logs requests --query 'cacheReason:stale_error'` (needs Observability Plus or a Priority project), or aggregate with `vercel metrics vercel.request.count --group-by cache_reason` — the `x-vercel-cache-reason` header is internal-only and not visible via `curl`. + A raw `MISS` with reason `draft_mode` / `prerender_bypass` / `crawler` is **displayed as `BYPASS`** (all usually expected). The three `stale_*` reasons separate a healthy time refresh (`stale_time`) from a broad-tag blast (`stale_tag`) from a failing regen (`stale_error`). Read `cacheReason` from the dashboard Logs "Reason" row, find matching requests with `vercel logs requests --query 'cacheReason:stale_error'` (needs Observability Plus or a Priority project), or aggregate with `vercel metrics vercel.request.count --group-by cacheReason` — the `x-vercel-cache-reason` header is internal-only and not visible via `curl`. - **PPR state** (`ppr_state`) — for a Partial Prerendering route, _how much_ of the response was prerendered versus computed per request. Only set on `partial_prerender` serves; blank for plain `prerender` / `func` / `static` routes and for cases the proxy can't classify (cold shell miss, `BYPASS`). Three states: @@ -135,35 +135,35 @@ Vercel caches at multiple layers between the visitor and your backend. A request | Partial | A static shell serves from cache + a postponed hole the function resumes per request | | Dynamic | The whole body is postponed and rendered by the function per request | - A **Partial** serve that still invokes the function is _not_ a cache miss — the cached shell serves immediately while the function fills only the dynamic holes. Read `ppr_state` from the dashboard Logs panel, filter on `pprState` with `vercel logs requests --query` (needs Observability Plus or a Priority project), or aggregate with `vercel metrics vercel.request.count --group-by ppr_state`. Like `cacheReason`, the `x-vercel-ppr-state` header is internal-only and not visible via `curl`. + A **Partial** serve that still invokes the function is _not_ a cache miss — the cached shell serves immediately while the function fills only the dynamic holes. Read `ppr_state` from the dashboard Logs panel, filter on `pprState` with `vercel logs requests --query` (needs Observability Plus or a Priority project), or aggregate with `vercel metrics vercel.request.count --group-by pprState`. Like `cacheReason`, the `x-vercel-ppr-state` header is internal-only and not visible via `curl`. ## Investigating cache issues Reach for the Vercel CLI. `vercel metrics` gives aggregate numbers (requires [Observability Plus](https://vercel.com/docs/observability/observability-plus)); `vercel logs requests` shows per-request CDN behavior (status, cache result, path), and `vercel logs` shows the runtime logs a request produced. -Metrics need to be queried by team and project (`-S -p `). Filter production with `--environment production` (equivalent to `--query 'environment:production'`; the CLI's filter syntax is KQL — the older OData `eq`/`and` syntax is deprecated). `--query`/`-q` needs Vercel CLI 65.4+ (older CLIs use `--filter`/`-f`), and `--environment` needs 64.7+ (older CLIs use `--prod`). Run `vercel metrics schema ` to discover dimensions; use `--json` for machine-readable output (CLI 58.1+; older CLIs use `--format json`). Remember **`--limit` is per time bucket** — with no `--granularity`, the CLI still picks a bucket size for the range. +Metrics need to be queried by team and project (`-S -p `). Filter production with `--environment production` (equivalent to `--query 'environment:production'`; the CLI's filter syntax is KQL — the older OData `eq`/`and` syntax is deprecated). `--query`/`-q` needs Vercel CLI 65.4+ (older CLIs use `--filter`/`-f`), and `--environment` needs 64.7+ (older CLIs use `--prod`). Run `vercel metrics schema ` to discover dimensions; use `--json` for machine-readable output (CLI 58.1+; older CLIs use `--format json`). Since CLI 59.12, `vercel metrics` queries the Observability metrics API by default, which names dimensions in camelCase (`cacheResult`, `requestPath`; set `FF_LEGACY_METRICS=1` to fall back to the legacy API and its snake_case names). The `pprState`, `cache_tags`, and `triggering_tag` names below aren't confirmed against the new schema, so check them with `vercel metrics schema vercel.request.count` (or `vercel metrics schema vercel.isr_operation`) before you run them. Remember **`--limit` is per time bucket** — with no `--granularity`, the CLI still picks a bucket size for the range. ### Cache hit rate Start here for an overall picture of how well caching is working. -**Step 1 — overall split.** Group `vercel.request.count` by `cache_result`. Treat `HIT`, `STALE`, and `PRERENDER` as cache-served; focus investigation on `MISS`. Exclude `BYPASS` and `(not set)` when computing a hit rate over _cacheable_ traffic (see [Debugging BYPASS traffic](#debugging-bypass-traffic)). `STALE` means stale-while-revalidate is working — dig into revalidation frequency in [Analyzing ISR costs](#analyzing-isr-costs), not here. +**Step 1 — overall split.** Group `vercel.request.count` by `cacheResult`. Treat `HIT`, `STALE`, and `PRERENDER` as cache-served; focus investigation on `MISS`. Exclude `BYPASS` and `(not set)` when computing a hit rate over _cacheable_ traffic (see [Debugging BYPASS traffic](#debugging-bypass-traffic)). `STALE` means stale-while-revalidate is working — dig into revalidation frequency in [Analyzing ISR costs](#analyzing-isr-costs), not here. ```bash vercel metrics vercel.request.count -S -p \ - --environment production --group-by cache_result --since 24h + --environment production --group-by cacheResult --since 24h ``` -**Step 2 — where misses concentrate.** Split the `MISS` bucket (and optionally `STALE`) by `path_type`, then by `route` or `request_path`: +**Step 2 — where misses concentrate.** Split the `MISS` bucket (and optionally `STALE`) by `pathType`, then by `route` or `requestPath`: ```bash vercel metrics vercel.request.count -S -p \ - --environment production -q "cache_result:MISS" \ - --group-by path_type --since 24h + --environment production -q "cacheResult:MISS" \ + --group-by pathType --since 24h vercel metrics vercel.request.count -S -p \ - --environment production -q "cache_result:MISS AND path_type:prerender" \ - --group-by request_path --since 24h + --environment production -q "cacheResult:MISS AND pathType:prerender" \ + --group-by requestPath --since 24h ``` **What to expect:** `prerender` routes (static shells, ISR pages) should show a high share of `HIT`/`PRERENDER`. A `prerender` path with a disproportionate `MISS` count is your short list for per-path header inspection (`curl` above) and code review. @@ -186,7 +186,7 @@ vercel metrics vercel.isr_operation.write_units -S -p --aggrega ```bash # numerator: cache serves — sum the HIT + STALE + PRERENDER buckets vercel metrics vercel.request.count -S -p \ - --environment production -q "cache_result:(HIT OR STALE)" \ + --environment production -q "cacheResult:(HIT OR STALE)" \ --group-by route --aggregation sum --since 24h # denominator: ISR writes vercel metrics vercel.isr_operation.write_units -S -p \ @@ -195,17 +195,17 @@ vercel metrics vercel.isr_operation.write_units -S -p \ High is good; near or below ~1 means you regenerate about as fast as the page is read (wasted writes) → lengthen the revalidate interval or move time-based to on-demand tag revalidation. -**Which routes revalidate most.** Break write units down by `route` and `request_path` to find paths that regenerate often relative to traffic: +**Which routes revalidate most.** Break write units down by `route` and `requestPath` to find paths that regenerate often relative to traffic: ```bash vercel metrics vercel.isr_operation.write_units -S -p \ --aggregation sum --group-by route --since 24h vercel metrics vercel.isr_operation.write_units -S -p \ - --aggregation sum --group-by request_path --since 24h + --aggregation sum --group-by requestPath --since 24h ``` -**Regeneration vs. serving.** Group write units by `path_type` — concentration in `background_func` confirms revalidation (not per-request dynamic work) is the cost driver. +**Regeneration vs. serving.** Group write units by `pathType` — concentration in `background_func` confirms revalidation (not per-request dynamic work) is the cost driver. **Time-based vs. tag-based revalidation.** Time-based intervals regenerate on a schedule whether or not content changed — often inefficient. Tag-based on-demand revalidation is usually better, but an **overly broad tag** has a large blast radius: one invalidate drops every entry that carries it. @@ -235,13 +235,13 @@ Before tuning headers or revalidate intervals, confirm what's left after those t ```bash vercel metrics vercel.request.count -S -p \ - -q "cache_result:BYPASS" --group-by bot_category --since 24h + -q "cacheResult:BYPASS" --group-by botCategory --since 24h vercel metrics vercel.request.count -S -p \ - -q "cache_result:BYPASS" --group-by user_agent --since 24h + -q "cacheResult:BYPASS" --group-by clientUserAgent --since 24h vercel metrics vercel.request.count -S -p \ - -q "cache_result:BYPASS" --group-by request_method --since 24h + -q "cacheResult:BYPASS" --group-by requestMethod --since 24h ``` The **Firewall/WAF** with the `vercel-firewall` skill can be used to manage verified SEO crawlers, block abusive bots, and rate-limit junk traffic before it distorts your hit-rate picture. From ffecb6ad624de2ade298469f661698a833237c33 Mon Sep 17 00:00:00 2001 From: molebox Date: Thu, 26 Nov 2026 12:05:11 +0100 Subject: [PATCH 2/2] [skills] cdn-caching: finish camelCase metrics dimensions, bound FF_LEGACY_METRICS, drop sum on request count - `cache_tags` -> `cacheTags` and `triggering_tag` -> `triggeringTag` in the `vercel metrics` examples, and drop the "aren't confirmed" note. The Observability metrics API accepts only its camelCase catalog names: `vercel.request.count` lists `cacheTags`, `cacheReason`, `pprState` and `triggeringTag`; `vercel.isr_operation.*` lists `cacheTags` and has no `triggeringTag`. - `FF_LEGACY_METRICS=1` exists only on CLI 59.12-65.11. CLI 65.12.0 removed it and always uses the Observability metrics API. - Drop `--aggregation sum` from the two `vercel.request.count` commands. Count metrics accept only `count` and `unique` on the Observability metrics API, and the CLI picks `count` when the flag is omitted. - Say what CLIs before 59.12 need: the legacy API's snake_case names and OData filters. Sources: - @vercel/o11y-tools@0.105.0/dist/contracts/metrics.mjs (metric catalog: `countAggregations` is ["count", "unique"] and `vercel.request.count` is a count metric over `incomingRequestDimensions`, which lists `cacheTags`, `pprState` and `triggeringTag`; `isrOperationDimensions` lists `cacheTags` and no `triggeringTag`) - vercel@59.11.7 dist (new API opt-in via FF_METRICS), vercel@59.12.0 dist (FF_LEGACY_METRICS added) - @vercel/cli-support@65.11.0/dist/chunks/query-67KQVLTR.js (FF_LEGACY_METRICS present), @vercel/cli-support@65.12.0 dist (FF_LEGACY_METRICS absent from every file) - vercel/vercel@155eacfa1684:packages/cli/CHANGELOG.md (59.12.0 ef5c9f7, 59.16.0 0239c8e) - vercel/vercel@155eacfa1684:packages/cli/src/commands/metrics/query.ts (default aggregation falls back to count; group-by and filter names are sent unchanged) - vercel/vercel@155eacfa1684:packages/cli/src/commands/metrics/command.ts (legacy API: OData filters, snake_case names) - https://vercel.com/docs/cli/metrics --- skills/cdn-caching/SKILL.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/skills/cdn-caching/SKILL.md b/skills/cdn-caching/SKILL.md index a9623b24..81a3ce2f 100644 --- a/skills/cdn-caching/SKILL.md +++ b/skills/cdn-caching/SKILL.md @@ -141,7 +141,7 @@ Vercel caches at multiple layers between the visitor and your backend. A request Reach for the Vercel CLI. `vercel metrics` gives aggregate numbers (requires [Observability Plus](https://vercel.com/docs/observability/observability-plus)); `vercel logs requests` shows per-request CDN behavior (status, cache result, path), and `vercel logs` shows the runtime logs a request produced. -Metrics need to be queried by team and project (`-S -p `). Filter production with `--environment production` (equivalent to `--query 'environment:production'`; the CLI's filter syntax is KQL — the older OData `eq`/`and` syntax is deprecated). `--query`/`-q` needs Vercel CLI 65.4+ (older CLIs use `--filter`/`-f`), and `--environment` needs 64.7+ (older CLIs use `--prod`). Run `vercel metrics schema ` to discover dimensions; use `--json` for machine-readable output (CLI 58.1+; older CLIs use `--format json`). Since CLI 59.12, `vercel metrics` queries the Observability metrics API by default, which names dimensions in camelCase (`cacheResult`, `requestPath`; set `FF_LEGACY_METRICS=1` to fall back to the legacy API and its snake_case names). The `pprState`, `cache_tags`, and `triggering_tag` names below aren't confirmed against the new schema, so check them with `vercel metrics schema vercel.request.count` (or `vercel metrics schema vercel.isr_operation`) before you run them. Remember **`--limit` is per time bucket** — with no `--granularity`, the CLI still picks a bucket size for the range. +Metrics need to be queried by team and project (`-S -p `). Filter production with `--environment production` (equivalent to `--query 'environment:production'`; the CLI's filter syntax is KQL — the older OData `eq`/`and` syntax is deprecated). `--query`/`-q` needs Vercel CLI 65.4+ (older CLIs use `--filter`/`-f`), and `--environment` needs 64.7+ (older CLIs use `--prod`). Run `vercel metrics schema ` to discover dimensions; use `--json` for machine-readable output (CLI 58.1+; older CLIs use `--format json`). Since CLI 59.12, `vercel metrics` queries the Observability metrics API by default, which names dimensions in camelCase (`cacheResult`, `requestPath`, `cacheTags`) and counts requests with the `count` aggregation (the default for `vercel.request.count`; `--aggregation sum` is rejected there). Before 59.12 the CLI queries the legacy API, which uses snake_case names (`cache_result`, `request_path`) and OData filters; `FF_LEGACY_METRICS=1` switches back to it only on CLI 59.12–65.11 (65.12 removed the flag). Remember **`--limit` is per time bucket** — with no `--granularity`, the CLI still picks a bucket size for the range. ### Cache hit rate @@ -177,7 +177,7 @@ Once you know hit rate, quantify ISR spend and whether revalidation — not traf **Utilization vs. ISR billing.** **Utilization** is `vercel.request.count` — total request volume. **ISR cost** is billed separately in 8 KB units: `read_units` when the regional CDN misses and falls through to the ISR cache, and `write_units` when a revalidation/regeneration produces changed output (unchanged content incurs none). The regional CDN shields ISR heavily — most requests never touch the ISR layer, so **read_units will be far below request count**. Do not compare read_units to write_units as a utilization check; focus on **write_units** (revalidation cost) and how they relate to total traffic. ```bash -vercel metrics vercel.request.count -S -p --aggregation sum --since 24h +vercel metrics vercel.request.count -S -p --since 24h vercel metrics vercel.isr_operation.write_units -S -p --aggregation sum --since 24h ``` @@ -187,7 +187,7 @@ vercel metrics vercel.isr_operation.write_units -S -p --aggrega # numerator: cache serves — sum the HIT + STALE + PRERENDER buckets vercel metrics vercel.request.count -S -p \ --environment production -q "cacheResult:(HIT OR STALE)" \ - --group-by route --aggregation sum --since 24h + --group-by route --since 24h # denominator: ISR writes vercel metrics vercel.isr_operation.write_units -S -p \ --environment production --group-by route --aggregation sum --since 24h @@ -209,18 +209,18 @@ vercel metrics vercel.isr_operation.write_units -S -p \ **Time-based vs. tag-based revalidation.** Time-based intervals regenerate on a schedule whether or not content changed — often inefficient. Tag-based on-demand revalidation is usually better, but an **overly broad tag** has a large blast radius: one invalidate drops every entry that carries it. -- **Tag blast radius** — group write units by `cache_tags`. If many _unrelated_ routes show near-identical write counts, a shared hot tag is invalidating them in lockstep (e.g. every blog post rewriting at the same rate because they share one broad `blogPost` tag): +- **Tag blast radius** — group write units by `cacheTags`. If many _unrelated_ routes show near-identical write counts, a shared hot tag is invalidating them in lockstep (e.g. every blog post rewriting at the same rate because they share one broad `blogPost` tag): ```bash vercel metrics vercel.isr_operation.write_units -S -p \ - --aggregation sum --group-by cache_tags --since 24h + --aggregation sum --group-by cacheTags --since 24h ``` -- **What triggered revalidation** — group `vercel.request.count` by `triggering_tag` to see which tags fire most often (`triggering_tag` is on request count only, not ISR operation metrics. It is one of the tags that triggered the page to be stale): +- **What triggered revalidation** — group `vercel.request.count` by `triggeringTag` to see which tags fire most often (`triggeringTag` is on request count only, not ISR operation metrics. It is one of the tags that triggered the page to be stale): ```bash vercel metrics vercel.request.count -S -p \ - -q "triggering_tag:*" --group-by triggering_tag --since 24h + -q "triggeringTag:*" --group-by triggeringTag --since 24h ``` Tags with a large blast radius that revalidate frequently are the usual root cause of high write_units. Prefer granular tags (`product-${id}`) and on-demand invalidation over short time-based intervals for event-driven content.