A Release Changes More Than One Cached URL
At 22:00, a deploy publishes version 42 of a small shop. The homepage shows the new price, but the layout is last week's: the “Buy” button is in the old place and the gallery is empty. Every file is valid; they just do not belong to the same release.
Think of a newspaper. The front page is reprinted each edition, while advertising inserts are printed once per edition with an edition number. Today's front page with yesterday's insert is not corrupt; the artifacts are from different editions. HTML is the front page: it changes often and keeps a stable URL. Fingerprinted assets are the inserts: their names change with their contents, so they can be cached for a long time.
Five words that decide a release
A cache entry is a stored response plus metadata — key, headers, age, and tags. Its cache key is that entry's identity: by default the full URL plus a few request headers. Freshness is how long the entry may be served without asking the origin; a shared-cache lifetime and an Edge TTL set it, and the response's age reports how old the copy is. A purge deletes entries, while an invalidation keeps them but marks them stale so the next request revalidates. A fingerprint is a content hash in a filename, such as app.7f3c9.js.
The mental model: a release is a graph of URLs, not a file. HTML points to script, style, image, and API URLs, and each edge is cached independently. Consistency means every edge resolves to an artifact that exists and agrees with the HTML naming it. Purging one node does not rewrite the edges.
%%{init: {'theme':'base','themeCSS':'.edgeLabel .label text, .edgeLabel text, .edgeLabel span { fill:#132440 !important; color:#132440 !important; }','themeVariables': {'primaryColor':'#16476A','primaryTextColor':'#ffffff','primaryBorderColor':'#132440','secondaryColor':'#3B9797','secondaryTextColor':'#ffffff','secondaryBorderColor':'#132440','tertiaryColor':'#c4873b','tertiaryTextColor':'#132440','tertiaryBorderColor':'#132440','lineColor':'#5a6e82','textColor':'#132440','titleColor':'#132440','mainBkg':'#16476A','nodeBorder':'#132440','clusterBkg':'#eef3f7','clusterBorder':'#132440','edgeLabelBackground':'#ffffff','actorBkg':'#16476A','actorTextColor':'#ffffff','actorBorder':'#132440','activationBkgColor':'#3B9797','activationBorderColor':'#132440','signalColor':'#5a6e82','signalTextColor':'#132440','noteBkgColor':'#c4873b','noteTextColor':'#132440','noteBorderColor':'#132440','labelBoxBkgColor':'#a8dede','labelBoxBorderColor':'#132440','labelTextColor':'#132440','loopTextColor':'#132440','altBackground':'#f8f9fa','fontFamily':'DM Sans, sans-serif'}}}%%
flowchart TD
R["Release v42"] --> H["index.html
mutable, short TTL"]
R --> A["app.7f3c9.js
immutable, long TTL"]
R --> I["hero.9a1d.webp
immutable"]
R --> J["/api/feed.json
usually DYNAMIC"]
H --> K["Cache key
host + path + query"]
A --> K
I --> K
J --> D["Dynamic path
no shared entry"]
K --> P1["PoP A entry"]
K --> P2["PoP B entry"]
P1 --> B["Browser"]
P2 --> B
H -.->|purge this URL only| X["Old HTML still names
old asset hashes"]
X --> Y["Mixed-version page"]
classDef primary fill:#132440,color:#ffffff,stroke:#0b172b;
classDef secondary fill:#16476A,color:#ffffff,stroke:#0f314a;
classDef ok fill:#3B9797,color:#ffffff,stroke:#2a6f6f;
classDef danger fill:#BF092F,color:#ffffff,stroke:#7a0420;
classDef warn fill:#c4873b,color:#132440,stroke:#8a5a1f;
class R,H,A,I,J,K,D,P1,P2,B,X,Y secondary;
Figure 1 shows why one deploy produces several cache decisions: HTML, script, image, and API response travel different paths, and purging the HTML does not touch the script entry.
Figure 2 draws the release boundary, the cache-key boundary that decides which requests share an entry, and the per-PoP boundary that decides what a visitor sees. A release can be correct at the origin and wrong at one edge.
Deletion is global; refill is local and lazy. Cloudflare describes purge as removing content “in every Cloudflare data center and cache tier, including Cache Reserve,” after which each data center repopulates its own entry. Apparent lag is refill, not deletion: two visitors can see different ages, or one miss and one hit, without either request being wrong.
Versioned Assets and Mutable HTML
Separate the release into two policies, not one site-wide TTL. A fingerprinted asset gets a new URL whenever its bytes change: app.7f3c9.js can be cached for a year because the next release publishes a new hash. HTML keeps a stable path, so its content moves while its URL does not; it needs a short window or a purge, while hashed assets should normally never be purged.
Put the policy in the response headers, not in prose. A static asset can carry a one-year shared-cache lifetime plus an immutable browser hint — but that hint only changes browser behavior, and the edge lifetime comes from the shared max-age. HTML needs a Cache Rule before Cloudflare will cache it at all; after that, you own its invalidation. The table below separates the three object classes and their failure modes.
Default TTLs are not a release policy
Without a cache-control header or an expiry date, Cloudflare's default edge TTL is 120 minutes for a 200, 206, or 301 response, 20 minutes for a 302 or 303, and 3 minutes for a 404 or 410. Those defaults suit static files, not releases: cacheable HTML can sit for two hours unless you set an explicit TTL or a revalidation directive.
| Object or decision | Recommended treatment and reason |
|---|---|
app.7f3c9.js or style.4a1e.css | One-year max-age plus an immutable browser hint; change the filename when the bytes change; do not purge on normal releases. |
/index.html or / | Stable URL, short edge TTL or revalidation, purge by URL or release tag when the document changes. HTML is not cached by default. |
/api/feed.json | Not cached by default. private, no-store for personalized data; if genuinely public, an explicit shared-cache policy and its own invalidation plan. |
| Rollback | Republish the previous HTML and keep the previous hashed assets reachable; purge the HTML, not the asset namespace. |
| Emergency correction | Purge URL, then tag or prefix, then host, then everything. Broad purges trade correctness for origin load. |
| Cache key | Keep it stable across a release; custom header, cookie, host, and user-feature inputs are Enterprise-only and complicate URL purges. |
Figure 3 follows compatibility through a deploy. The dangerous branch is old HTML served after its asset was deleted, or new HTML served before its assets exist.
%%{init: {'theme':'base','themeCSS':'.edgeLabel .label text, .edgeLabel text, .edgeLabel span { fill:#132440 !important; color:#132440 !important; }','themeVariables': {'primaryColor':'#16476A','primaryTextColor':'#ffffff','primaryBorderColor':'#132440','secondaryColor':'#3B9797','secondaryTextColor':'#ffffff','secondaryBorderColor':'#132440','tertiaryColor':'#c4873b','tertiaryTextColor':'#132440','tertiaryBorderColor':'#132440','lineColor':'#5a6e82','textColor':'#132440','mainBkg':'#16476A','nodeBorder':'#132440','clusterBkg':'#eef3f7','clusterBorder':'#132440','edgeLabelBackground':'#ffffff','actorBkg':'#16476A','actorTextColor':'#ffffff','actorBorder':'#132440','activationBkgColor':'#3B9797','activationBorderColor':'#132440','signalColor':'#5a6e82','signalTextColor':'#132440','noteBkgColor':'#c4873b','noteTextColor':'#132440','noteBorderColor':'#132440','labelBoxBkgColor':'#a8dede','labelBoxBorderColor':'#132440','labelTextColor':'#132440','loopTextColor':'#132440','altBackground':'#f8f9fa','fontFamily':'DM Sans, sans-serif'}}}%%
flowchart TD
D["Deploy v42"] --> U["Upload new hashed assets"]
U --> H["Publish HTML that names new hashes"]
H --> Q{"HTML served from cache?"}
Q -->|yes, old copy| O["Old HTML names old hashes"]
O --> E{"Old assets still stored?"}
E -->|yes| OK["Old page renders"]
E -->|no| B["404 or broken page"]
Q -->|no, fresh copy| N["New HTML names new hashes"]
N --> F{"New assets present?"}
F -->|yes| G["New page renders"]
F -->|no| B2["404 or broken page"]
B --> R["Rollback: restore old HTML"]
R --> OK
classDef primary fill:#132440,color:#ffffff,stroke:#0b172b;
classDef secondary fill:#16476A,color:#ffffff,stroke:#0f314a;
classDef ok fill:#3B9797,color:#ffffff,stroke:#2a6f6f;
classDef danger fill:#BF092F,color:#ffffff,stroke:#7a0420;
classDef warn fill:#c4873b,color:#132440,stroke:#8a5a1f;
class D,U,H,O,E,OK,B,N,F,G,B2,R secondary;
class Q ok;
Do not copy an Enterprise recipe into a Free zone
Current purge documentation lists URL, hostname, tag, prefix, and purge-everything selectors on all plans, so tags are no longer Enterprise-only. Cache-key inputs are the uneven part: header, cookie, host, user-feature, and specific query-string inputs are Enterprise-only, while ignore-query-string and sort-query-string work everywhere. Device-type keys exist on all plans, yet dashboard purges with device or country variants are Enterprise. Check the plan before copying a recipe.
Purge Scope and Cache-Key Dependencies
Purge scope is a blast-radius choice, not a freshness setting. Each selector reaches a different set of cache keys, so pick the narrowest one that covers the change.
| Selector | What it removes | Blast radius | Watch out for |
|---|---|---|---|
| URL | The entry for one cache key | One URL in the current variant | Custom-key headers or cookies must match; a dashboard purge cannot send them |
| Tag | Every cached response carrying the tag | Every URL tagged for that release | Tags exist only on cached responses, and a Worker must re-set the header |
| Host | Every URL on a hostname | One host, all paths | Reaches far beyond one release |
| Prefix | Everything under a host plus path | A path subtree | Easy to overlap with unrelated apps on the same host |
| Everything | The whole zone | Every cached object | Origin load on refill; not a first move |
Hard removal versus soft invalidation
A purge is hard removal: the entry is deleted and will not be served again, even if the origin is unavailable. Invalidation is soft: it keeps the content, marks it stale, and asks the origin to confirm it with an ETag or a Last-Modified date; a 304 lets Cloudflare reuse the body and reset its TTL. Stale content can be served while that revalidation runs, and on origin failure for as long as it stays in cache.
Tags are the design tool for large sites. Use a small, stable vocabulary rather than one tag per URL — a release tag such as html-release-2026-11-04, plus product, tenant, and content-type tags where they earn their keep. Tag HTML with the release you purge on deploy; tag assets only if an emergency purge must reach them.
Keep tag names boring and bounded. Tags are case-insensitive, cannot contain spaces, and travel in Cache-Tag, which Cloudflare strips before the response reaches the visitor or a Worker — a Worker that re-stores a response must set it again. The aggregate header is capped at 16 KB (about 1,000 tags), and a single purge tag at 1,024 characters.
A tag only works on a cached response. If the HTML is dynamic, a tag changes nothing; make it cacheable first. A 304 does not refresh tags set by Cache Response Rules, and origin tags refresh only if the tag header appears on the 304. Purge when tag changes matter.
“Surrogate keys” are another vendor's term. Cloudflare's purge input is Cache-Tag, optionally modified by Cache Response Rules; the older Surrogate-Key and Surrogate-Control pair is not documented as a purge input even in the 2026-11-04 cache docs. A migration should translate the header and test one purge — sending both and assuming both are consumed can leave content behind.
One selector family per request. The body carries either files, tags, hosts, prefixes, or the purge-everything flag, and that flag must be the only field. A custom key needs its values echoed back exactly.
A Cache Rule that matches only GET will not match the internal PURGE request. Cloudflare sends its own purge method, so a rule that excludes it — or that matches a field unavailable during purge — will not behave as it does for a visitor. For a custom key, every header or cookie in the key must be present, because a missing value is treated as empty. A dashboard URL purge cannot send those values, so use the API, a prefix purge, a tag purge, or purge everything.
Quotas are per account, not per zone, and the bill is refill. At the time of writing, tag, host, prefix, and purge-everything requests range from 5 per minute on Free to 50 per second on Enterprise, with 100 operations per request. The purge call itself is free; origin egress, misses, and retained Cache Reserve storage are not. A URL purge deletes matching Cache Reserve content, but a broader selector does not, so storage can keep billing until replacement or retention ends.
Purge is not a rollback
Purging the HTML does not remove the old hashed JavaScript it references, and a success response from the purge API only means Cloudflare accepted the request — not that any entry was evicted. Verify with a later request: a miss, then a hit with a reset age. A purge selects entries; it does not select a release.
A Decision Tree for Stale or Missing Content
Resist purging first. A purge destroys evidence and can turn a narrow bug into an origin spike. Diagnose in a fixed order and record what you observed.
Start with the exact request identity. Record the URL, host, and variant, then read the cache status, the response age, and the ray ID. The last three characters of the ray ID are the data center code, so different suffixes may mean different PoPs. Ray IDs correlate requests but are not guaranteed unique; never use one as a database key.
Then read the status as a decision:
| Status | What it means | Age reported? | Next check |
|---|---|---|---|
DYNAMIC | Not eligible at request time | No | Cache Rule, bypass rule, method, or Development Mode (suspends cache for three hours) |
BYPASS | Eligible but not storable | No | no-store, bare private, Set-Cookie, Vary: *, oversized object, or Authorization without a public/shared directive under Origin Cache Control |
MISS on repeats | The key varies, or the entry was not there | No | Query variants, custom-key inputs, device type, PoP, eviction |
HIT with a large Age | An old entry survived the purge | Yes | Wrong URL, host, variant, redirect, Transform path, custom-key headers |
EXPIRED | Origin served a new body | No on revalidation | Whether the origin actually changed |
REVALIDATED | Origin confirmed with a 304 | No | The origin's validator behavior |
UPDATING | Background refresh is serving old content | Yes | stale-while-revalidate window |
STALE | Origin is unreachable | Yes | Origin health and stale-if-error |
Figure 4 turns those readings into branches: first “was this cacheable?”, then “did the request map to the entry we thought?”, and only then “should we purge?”.
Age is not a universal clock. Cloudflare sets it on hits, stale responses, and background updates, but not on misses, dynamic or bypassed responses, or a revalidated response. A missing age is not evidence that the cache was bypassed.
Tiered Cache changes what the lower tier reports. It may show an expired or missed entry while revalidating upward, an age that reflects network-wide age, and a first hit after an upper-tier fill with no age at all. Neither observation proves a purge failed.
Freshness is a product decision
A stale-while-revalidate window trades bounded staleness for lower latency, and Cloudflare's implementation is asynchronous, so requests during the window see a background update. A stale-if-error window protects availability when the origin fails, and Cloudflare can serve stale content for as long as it stays in cache even without the directive; set a limit, or set it to zero, when old content is unacceptable. Prices, entitlements, and legal notices need a short TTL, no stale window, and a hard purge; a blog index or product image usually prefers a stale window to an origin spike.
Publish Two Versions of a Small Static Site
Publish Two Versions of a Small Static Site
Status: design-only. This exercise was not executed against a Cloudflare zone for this draft; expected observations are documented behavior, not measurements. Use a disposable hostname.
Prerequisites. A Cloudflare zone on any plan, one proxied test hostname, origin file control, curl, and header control. The exercise uses a Cache Rule because Cloudflare does not cache HTML by default; without rules, the HTML stays dynamic and only the asset half works.
Minimal setup. Two folders, each with an HTML file and its matching asset pair. Upload both asset sets before publishing either HTML. Assets get a one-year immutable lifetime; HTML gets a 60-second edge TTL through a Cache Rule. Tag each HTML file with its release name.
Steps.
- Publish v1 HTML and request the root twice with curl; record the cache status, age, and ray ID. The first should be a miss or dynamic; the second should be a hit if the rule is active.
- Request the v1 asset twice; expect a hit on the second and an increasing age.
- Publish v2 assets, then v2 HTML; request the root repeatedly and record the status and asset URLs.
- Purge the HTML by URL with
{"files":["https://test.example.com/"]}. Request the root immediately; expect a miss, then a hit with a smaller age. A hit carrying the old age means the purge missed the key. - Request the v2 asset URLs from the returned HTML. Expect a 200; a 404 means publication order is wrong.
- Roll back by republishing v1 HTML while leaving v2 assets in place; purge the HTML URL. Confirm the page uses v1 asset URLs and those assets still return a 200.
- Failure check: rename an asset, request the cached v1 HTML, and observe the 404. Restore it. Old hashed assets must outlive the HTML that references them.
- Tag check: purge the v2 release tag with the tag request shown above, then repeat step 4. With Tiered Cache, expect a miss or an expired response; either can be correct.
Success. HTML changes after a purge, v2 assets resolve, and rollback resolves from v1 assets. Failure signature. A hit with an age older than the purge — record URL, host, ray ID, and key inputs. Wrong rule. If HTML stays dynamic, the rule did not make it eligible. Wrong reading. If a tag purge returns expired, check Tiered Cache before calling it a failure.
Cost and cleanup. Purge requests are free, but refill is an origin request; two tiny files are negligible. If Cache Reserve is enabled, non-URL purges do not delete stored content immediately and storage can accrue. Delete the test hostname or zone, remove the rule and tags, purge everything once, and disable Development Mode.
Verify HTML and Assets Remain Compatible After Rollback
These are acceptance criteria, not results: the exercise is design-only, so no zone was deployed and nothing measured.
Pass/fail evidence.
- P1 — Separate policies. PASS if HTML and assets have distinct TTL and invalidation rules, and assets do not depend on a purge. FAIL if both use one long TTL or both are purged every deploy.
- P2 — Asset identity. PASS if changing an asset changes its URL and the old URL stays reachable. FAIL if a fixed
/app.jsis overwritten or old hashes are deleted at deploy. - P3 — Narrow purge. PASS if a release purges only the HTML URL or a release-specific tag, and the audit log shows that payload. FAIL if the pipeline purges everything or the log cannot explain the selector.
- P4 — Observable eviction. PASS if a post-purge request shows
MISS, thenHITwith a resetAge. FAIL if it staysHITwith the pre-purgeAge. - P5 — Rollback compatibility. PASS if restored HTML's asset URLs all return
200, including old hashes. FAIL if it renders mixed versions or any referenced file returns404. - P6 — Bounded blast radius. PASS if the runbook names the smallest selector and reserves purge-everything for emergencies. FAIL if the first response is a zone-wide purge.
Save full response headers, not just bodies. Capture the cache status, age, ray ID, cache-control policy, and every resolved asset URL. On the origin, record conditional requests and their 200 or 304 results. In the audit log, capture actor, time, and selector payload; Cloudflare added detailed payloads for all purge methods in November 2025.
Self-check.
- Why does purging
index.htmlnot guarantee a consistent release? HTML and each asset are separate entries under separate keys. Purging HTML removes one node; a browser cache or a different cache-key variant can still hold the old document, and new HTML can name an asset never published. Consistency needs assets first, old assets kept, and the HTML boundary purged. - A URL returns
HITwithAge: 900right after a purge. Two likely causes? The purge targeted a different key or variant — host, device or country, custom-key header, redirect, or Transform Rule path.Ageresets on purge, so a large value means this entry was not the one removed. - When is invalidation better than purge, and what is the risk? When content probably has not changed and you want a
304, avoiding a full re-fetch. The risk is serving stale content while revalidating or when the origin fails; if old is unacceptable, purge and constrainstale-if-error.
Unresolved limitations. No hosted Cloudflare lab was executed, so this article makes no claim about propagation time, measured hit rate, or exact status sequence for a given plan or region. Tiered Cache, Cache Reserve, Argo, and Version Management each change what a request reports; the decision tree describes documented branches, not every combination. Purge limits and pricing are dated; re-check them before implementation. The Surrogate-Key point is a documentation finding, not proof that no undocumented behavior exists. Ray IDs are not guaranteed unique; the data-center suffix is not a stable API.
Verification date and versions. Documentation reviewed 2026-11-04 against the Cloudflare Cache pages below. Tested product versions: none; no zone, origin, or API call was used. Commands use current curl syntax but were not run against Cloudflare for this draft.
References.
- Cloudflare Cache: https://developers.cloudflare.com/cache/
- Purge cache, including availability and limits: https://developers.cloudflare.com/cache/how-to/purge-cache/
- Purge by single file: https://developers.cloudflare.com/cache/how-to/purge-cache/purge-by-single-file/
- Purge by cache tags: https://developers.cloudflare.com/cache/how-to/purge-cache/purge-by-tags/
- Purge by hostname: https://developers.cloudflare.com/cache/how-to/purge-cache/purge-by-hostname/
- Purge by prefix: https://developers.cloudflare.com/cache/how-to/purge-cache/purge_by_prefix/
- Purge everything: https://developers.cloudflare.com/cache/how-to/purge-cache/purge-everything/
- Purge cached content API: https://developers.cloudflare.com/api/resources/cache/methods/purge/
- Invalidate cached content: https://developers.cloudflare.com/cache/guides/invalidate-cache/
- Cloudflare cache responses and
Age: https://developers.cloudflare.com/cache/concepts/cache-responses/ - Default cache behavior and TTLs: https://developers.cloudflare.com/cache/concepts/default-cache-behavior/
- Origin Cache Control: https://developers.cloudflare.com/cache/concepts/cache-control/
- Revalidation and stale-while-revalidate: https://developers.cloudflare.com/cache/concepts/revalidation/
- Cache keys and plan availability: https://developers.cloudflare.com/cache/how-to/cache-keys/
- Cache Response Rules: https://developers.cloudflare.com/cache/how-to/cache-response-rules/
- Cache Reserve purge and cost behavior: https://developers.cloudflare.com/cache/advanced-configuration/cache-reserve/
- Investigate uncached responses: https://developers.cloudflare.com/cache/troubleshooting/investigating-uncached-responses/
- Cloudflare Ray ID: https://developers.cloudflare.com/fundamentals/reference/cloudflare-ray-id/
- Purge audit logs changelog: https://developers.cloudflare.com/changelog/post/2025-11-25-audit-logs-for-cache-purge-events/
Next in the Series
In Measure Performance Before Turning on Optimizations, we'll explore Connect Core Web Vitals, mobile constraints, protocols, and scripts.