skip to content

In Cloudflare, how do Cache-Tag response headers let a sports-results site purge a match page, its JSON feed and league tables in one request?

level: middleimportance: must knowfreq 55%

answer

  1. label responses at the origin
  2. comma-separated, stripped at the edge
  3. tags in the purge body
  4. every plan since 2025

basics

~20 s

The origin adds a Cache-Tag header naming match-8812 to every response that shows that match's score. Cloudflare stores the tags with each cached object and strips the header. One purge by tag then removes every object carrying it, on any plan.

solid answer

~50 s

The origin labels each response with a `Cache-Tag` header, for example `Cache-Tag: match-8812,league-premier` on the match page, and adds `match-8812` to the feed and to every table and team page that shows that score. Cloudflare associates those tags with the cached object and **removes the header** before the response reaches the visitor or a Worker. When the score changes, one purge by tag, `{"tags": ["match-8812"]}` sent to the zone's `purge_cache` endpoint or **Custom Purge > Tag** in the dashboard, clears the match page, the JSON feed and every league table that carried the tag, wherever they are cached. Tags are case-insensitive, may not contain spaces, and the combined header may not exceed 16 KB, roughly 1,000 tags. One request lists up to 100 tags. Since April 2025 purge by tag is on every plan, and since March 2026 a Cache Response Rule can add tags when the origin cannot.

code

http · 4 lines
http
HTTP/1.1 200 OK
Content-Type: application/json
Cache-Control: public, max-age=60
Cache-Tag: match-8812,feed

go deeper

for a junior

Recall that the origin sends Cache-Tag with comma-separated tags and that a purge by tag clears every cached object carrying one of them.

for a middle

Explain the header rules (stripped at the edge, case-insensitive, no spaces, 16 KB), the tags list in the purge body, and why EXPIRED can follow a purge under Tiered Cache.

for a senior

Design tags around edit units, batch tag purges against the shared per-account bucket, and know Cache Response Rules or a Worker can tag responses the origin cannot.

for a principal

Weigh tag granularity against header size and CMS complexity, and decide whether one purge service owns tag purges for every zone on the account.

## Why tags instead of URLs When a sports-results site corrects a score, the stale number lives in many cached objects: the match page, the match's JSON feed, the league table, the team pages, perhaps an embeddable widget. Listing every URL is error-prone, because the CMS rarely knows every URL that quoted the score. A **cache tag** is a label attached to a cached response; Cloudflare can then purge **every object carrying a label** in one operation, in all data centers. Since April 2025 this purge by tag, along with purge by prefix, hostname and everything, is available on Free, Pro and Business plans, not only Enterprise. ## Tagging responses at the origin The origin adds a `Cache-Tag` HTTP response header listing the tags, separated by commas. Cloudflare applies these rules: - **Several tags per response**, and a response may carry more than one `Cache-Tag` header field. - **Whitespace around tags and repeated or trailing commas are removed**, so `tag1, tag2` and `tag1,,tag2` mean the same as `tag1,tag2`. - **No spaces inside a tag**, only printable ASCII characters, and at least one byte per tag. - **Case-insensitive**: `Match-8812` and `match-8812` are one tag. - **Size**: the combined header value may not exceed 16 KB, about 1,000 unique tags. In a purge API call a single tag may be at most 1,024 characters. - **Stripped at the edge**: Cloudflare removes `Cache-Tag` before sending the response to the visitor or handing it to a Worker, so nobody downstream sees your tag scheme. Tags only matter on responses Cloudflare actually caches, and the record must be proxied. HTML and JSON are not cached by default, so the match page and feed need a Cache Rule that makes them eligible; that setup belongs to the lesson on Cache Rules. ## A tag scheme for the scores site Tag by the unit an editor changes, not by page type: | Response | Tags | | --- | --- | | `/matches/8812` page | `match-8812,league-premier` | | `/api/matches/8812.json` feed | `match-8812,feed` | | `/leagues/premier/table` | `league-premier,match-8801,...,match-8812,...` | | `/teams/rovers` page | `team-rovers,match-8812,...` | Every object that displays a match's score carries that match's tag, so correcting match 8812 purges the single tag `match-8812`: the page, the feed, the table and both team pages go, and the other matches' pages stay cached. A league table carrying one tag per match of a season holds a few hundred short tags, well inside the 16 KB header limit. The `league-premier` tag stays available for purging a whole league at once. ## Purging by tag 1. Publish the correction at the origin first, so the refill fetches the right score. 2. Send `{"tags": ["match-8812"]}` to `POST /zones/{zone_id}/purge_cache`, or in the dashboard choose **Custom Purge**, then **Tag**, and enter the tags separated by commas or one per line. 3. Request one of the affected URLs and read `cf-cache-status`. After a tag purge the next request is normally a `MISS`. With **Tiered Cache** enabled you may see `EXPIRED` instead, because a lower-tier data center revalidates with its upper tier to spare it load. ## Limits that shape a tag design Purge by tag shares one limit set with purge by hostname, prefix and everything. The limits are **per account**, shared by every zone on the same plan, and enforced as a token bucket that refills at a steady rate: | Plan | Requests | Bucket size | | --- | --- | --- | | Free | 5 per minute | 25 | | Pro | 5 per second | 25 | | Business | 10 per second | 50 | | Enterprise | 50 per second | 500 | Each request carries at most 100 tags. A CMS that fires one purge per edit can drain a Free bucket during a busy match day, so batch tags from several edits into one request where you can. ## When the origin cannot send the header - **Cache Response Rules** (March 2026) run on the origin response before caching; their `set_cache_tags` action can `add`, `remove` or `set` tags from fixed values or from an expression, for example one that splits another header the origin already sends. - **A Worker** that stores responses with the Cache API can append `Cache-Tag` values to the response it stores, and those tags then work for purge by tag too. Either way, the purge side stays the same: one request, a list of tags, and every object carrying them is gone.

  • Why not give every page one site-wide tag and purge that?
    Purging a tag that every object carries is purge everything under another name: every page becomes a `MISS` and the origin takes the full refill at once. Tags pay off when they match what an editor changes, such as one match, one team or one league, so a correction clears only the objects that quoted it.
  • How do you check a tag purge worked when nobody can see Cache-Tag?
    Request a few of the tagged URLs and read `cf-cache-status`: `MISS`, or `EXPIRED` with Tiered Cache, then `HIT` with the new content. The API's 200 only acknowledges receipt. The account's audit logs also record each purge request with the list of tags it carried, which helps when an editor reports a correction that never appeared.
  • What do the purge limits mean for a CMS sending one tag purge per edit?
    Tag purges draw from a per-account token bucket shared by every zone on the same plan: 5 requests a minute with a bucket of 25 on Free, up to 50 a second with 500 on Enterprise, each request carrying at most 100 tags. Batching several edits' tags into one request keeps a busy match day inside the limit.

  • Purge by tag still needs an Enterprise plan.
  • Visitors can read the Cache-Tag header to see which tags a page has.
  • Cache tags are case-sensitive, so Match-8812 and match-8812 differ.
  • A response can carry only one cache tag.
  • Purging a tag immediately refetches every tagged page from the origin.

Assumes Cloudflare as of 2026-10-10: purge by tag reached every plan in April 2025 (it was Enterprise-only), and Cache Response Rules with set_cache_tags arrived in March 2026.