Back to Cloudflare

Release Fresh Content and Diagnose CDN Surprises

November 4, 2026 Updated November 5, 2026 Wasil Zafar 25 min read

Use explicit freshness policy and narrow invalidation

Table of Contents

  1. A Release Changes More Than One Cached URL
  2. Versioned Assets and Mutable HTML
  3. Purge Scope and Cache-Key Dependencies
  4. A Decision Tree for Stale or Missing Content
  5. Publish Two Versions of a Small Static Site
  6. Verify HTML and Assets Remain Compatible After Rollback

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.

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.

A Release Changes More Than One Cached URL
%%{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.

One release, several cache entries A release box points to three origin artifacts. The artifacts share a cache key and are stored as separate entries in two edge points of presence, then reach a browser. Release v42 one deploy many URLs Origin artifacts (release boundary) index.html mutable, short TTL stable URL app.7f3c9.js immutable, long TTL URL changes per release hero.9a1d.webp immutable image identity of one entry Cache key host + path + query string + optional headers (Enterprise) Edge PoPs (one entry per key) PoP A HTML v41 asset v41 Age: 840 seconds PoP B HTML v42 asset v42 Age: 35 seconds Browser gets one version Deleting an entry in one layer does not rewrite the HTML that points to another.

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 decisionRecommended treatment and reason
app.7f3c9.js or style.4a1e.cssOne-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.jsonNot cached by default. private, no-store for personalized data; if genuinely public, an explicit shared-cache policy and its own invalidation plan.
RollbackRepublish the previous HTML and keep the previous hashed assets reachable; purge the HTML, not the asset namespace.
Emergency correctionPurge URL, then tag or prefix, then host, then everything. Broad purges trade correctness for origin load.
Cache keyKeep 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.

Versioned Assets and Mutable HTML
%%{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.

SelectorWhat it removesBlast radiusWatch out for
URLThe entry for one cache keyOne URL in the current variantCustom-key headers or cookies must match; a dashboard purge cannot send them
TagEvery cached response carrying the tagEvery URL tagged for that releaseTags exist only on cached responses, and a Worker must re-set the header
HostEvery URL on a hostnameOne host, all pathsReaches far beyond one release
PrefixEverything under a host plus pathA path subtreeEasy to overlap with unrelated apps on the same host
EverythingThe whole zoneEvery cached objectOrigin load on refill; not a first move

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.

# Response header set by the origin or a Cache Response Rule
Cache-Tag: html-release-2026-11-04, type-html

# Purge request: one selector family per call
POST /zones/{zone_id}/purge_cache
Content-Type: application/json

{"tags":["html-release-2026-11-04"]}
# Purge the release tag after publishing HTML.
curl -sS -X POST \
  "https://api.cloudflare.com/client/v4/zones/$CLOUDFLARE_ZONE_ID/purge_cache" \
  -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
  -H "Content-Type: application/json" \
  --data '{"tags":["html-release-2026-11-04"]}'

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.

POST /zones/{zone_id}/purge_cache
Authorization: Bearer $CLOUDFLARE_API_TOKEN
Content-Type: application/json

{"files":[{"url":"https://shop.example.com/","headers":{"x-currency":"usd"}}]}
# A custom cache key must be reproduced exactly, or the purge hits a different entry.
curl -sS -X POST \
  "https://api.cloudflare.com/client/v4/zones/$CLOUDFLARE_ZONE_ID/purge_cache" \
  -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
  -H "Content-Type: application/json" \
  --data '{"files":[{"url":"https://shop.example.com/","headers":{"x-currency":"usd"}}]}'

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.

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.

# Two identical requests from the same network: compare status and age.
curl -sS -D - -o /dev/null https://test.example.com/
curl -sS -D - -o /dev/null https://test.example.com/

# Keep the full headers for evidence, including the ray ID.
curl -sS -D headers.txt -o /dev/null https://test.example.com/assets/app.v1.js

Then read the status as a decision:

StatusWhat it meansAge reported?Next check
DYNAMICNot eligible at request timeNoCache Rule, bypass rule, method, or Development Mode (suspends cache for three hours)
BYPASSEligible but not storableNono-store, bare private, Set-Cookie, Vary: *, oversized object, or Authorization without a public/shared directive under Origin Cache Control
MISS on repeatsThe key varies, or the entry was not thereNoQuery variants, custom-key inputs, device type, PoP, eviction
HIT with a large AgeAn old entry survived the purgeYesWrong URL, host, variant, redirect, Transform path, custom-key headers
EXPIREDOrigin served a new bodyNo on revalidationWhether the origin actually changed
REVALIDATEDOrigin confirmed with a 304NoThe origin's validator behavior
UPDATINGBackground refresh is serving old contentYesstale-while-revalidate window
STALEOrigin is unreachableYesOrigin 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?”.

Diagnose before purging An unexpected response leads to a cache-status decision, then to one of four branches: dynamic or bypass, repeated miss, hit with old age, or expired, updating, or stale. Each branch ends in a verification step. Unexpected or stale response Which status? and what Age? DYNAMIC / BYPASS not eligible or origin refused storage fix the rule or header MISS on repeats key variance, different PoP, eviction, or Development Mode HIT with old Age wrong variant, or the purge missed the exact cache key EXPIRED / UPDATING / STALE origin refresh, SWR, or origin failure Verify the fix MISS then HIT, Age resets, same cf-ray colo Then read origin logs and the purge audit log Purge is a repair action, not the first diagnostic step.

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

Guided exercise

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.

  1. 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.
  2. Request the v1 asset twice; expect a hit on the second and an increasing age.
  3. Publish v2 assets, then v2 HTML; request the root repeatedly and record the status and asset URLs.
  4. 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.
  5. Request the v2 asset URLs from the returned HTML. Expect a 200; a 404 means publication order is wrong.
  6. 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.
  7. 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.
  8. 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.

  1. 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.
  2. P2 — Asset identity. PASS if changing an asset changes its URL and the old URL stays reachable. FAIL if a fixed /app.js is overwritten or old hashes are deleted at deploy.
  3. 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.
  4. P4 — Observable eviction. PASS if a post-purge request shows MISS, then HIT with a reset Age. FAIL if it stays HIT with the pre-purge Age.
  5. 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 returns 404.
  6. 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.

  1. Why does purging index.html not 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.
  2. A URL returns HIT with Age: 900 right 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. Age resets on purge, so a large value means this entry was not the one removed.
  3. 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 constrain stale-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.