Every marketing campaign that appends ?utm_source=... to your URLs is quietly minting new cache entries: Cloudflare’s default cache key is host + path + full query string, so /promo.jpg?utm_campaign=spring and /promo.jpg?utm_campaign=fall are two different objects at the edge. The content is identical; the hit rate is halved. The fix is to take tracking parameters out of the cache key — with Cache Rules query-string settings on paid plans, or with origin-side and Worker workarounds on Free.
What’s happening
Requests flow browser → Cloudflare edge → origin, and the edge decides “have I seen this before?” purely by cache key. By default Cloudflare edge-caches static extensions only (images, CSS, JS, fonts — not HTML), and the key includes the query string verbatim: different order, different casing, or one extra parameter each produce a distinct entry.
Tracking parameters (utm_*, gclid, fbclid, msclkid) never change the response body, but they fragment the cache into as many copies as there are campaign links. Each fragment starts as a MISS, which means an origin fetch, which means the campaign traffic spike lands on your origin exactly when you wanted the edge absorbing it. If you cache HTML through a Cache Rule, the same splitting applies to pages — the highest-traffic case, since ad clicks always carry parameters. (APO ships its own handling for common tracking parameters, which is one reason WordPress sites on APO do not see this.)
The reverse trap exists too: ignore the query string wholesale and ?s=search-term or ?page=2 serve the wrong cached page to everyone. Query-string handling is an allowlist decision, not a switch.
What to check first
- Which parameters actually reach you. Pull the top query strings from your analytics or origin logs — the offenders are usually five tracking parameters, not fifty.
- Whether the split content is cached at all. If the URLs read
cf-cache-status: DYNAMIC, the query string is not your problem — cache eligibility is. - Where cache-busting relies on query strings. If deploys bust caches with
?v=123, removing the query string from the key silently disables that. - Your plan. Cache Rules exist on every plan (10 rules on Free, 25 Pro, 50 Business, 125 Enterprise), but cache-key customization depth is plan-dependent — full custom keys on cookies, headers, and device type are Enterprise features.
How to verify
Watch the cache split in real time — same object, different parameters:
curl -sI "https://example.com/img/promo.jpg" | grep -iE '^(cf-cache-status|age)'
curl -sI "https://example.com/img/promo.jpg" | grep -iE '^(cf-cache-status|age)'
curl -sI "https://example.com/img/promo.jpg?utm_source=newsletter" | grep -iE '^(cf-cache-status|age)'
curl -sI "https://example.com/img/promo.jpg?utm_source=facebook" | grep -iE '^(cf-cache-status|age)'
The bare URL goes MISS then HIT; each UTM variant starts over at MISS with age: 0 even though the second request without parameters was already hot. After you deploy normalization, the UTM variants should read HIT immediately, inheriting the bare URL’s entry. To confirm the body really is parameter-independent before you normalize, compare a cache-busted copy against the origin directly:
curl -s "https://example.com/img/promo.jpg?check=$(date +%s)" -o /tmp/edge.bin
curl -s "https://example.com/img/promo.jpg" --resolve example.com:443:203.0.113.10 -o /tmp/origin.bin
cmp /tmp/edge.bin /tmp/origin.bin && echo identical
The fix
- Inventory before you touch the key. List parameters that change the response (
s,page,id,lang,variant) and parameters that never do (utm_*,gclid,fbclid,msclkid,mc_cid). Anything ambiguous stays in the key. - On paid plans, normalize in Cache Rules. Caching → Cache Rules → your rule → Cache key: for static asset paths, ignore the query string entirely; where some parameters matter, use the include/exclude lists so only meaningful parameters remain in the key. Excluding the tracking list is safer than ignoring everything.
- On Enterprise, go further. Query-string sorting collapses
?a=1&b=2and?b=2&a=1into one entry, and full custom cache keys handle header- or device-based variants. - On Free, normalize before the cache. A small Worker that strips tracking parameters and fetches the cleaned URL makes the edge cache converge on one entry — the subrequest is keyed on the normalized URL. Alternatively, keep campaign parameters off cached asset URLs at the template level: tracking belongs on the landing page URL, not on every image and script it references.
- Do not strip parameters with redirects. A 301 that removes
utm_*before the page loads also removes them before your analytics script reads them — attribution dies. Normalize the cache key, not the visitor’s URL. - Re-point cache busting at filenames. If
?v=no longer varies the key, move to fingerprinted filenames (app.3f2a1c.js) — better practice anyway, as covered in stale content after a deploy.
When this fix is wrong
If the response genuinely varies with the parameter — search, pagination, filtering, API endpoints — normalizing serves wrong content and no amount of purging explains the reports away. If your hit rate is low because responses carry Set-Cookie or short TTLs, the query string is a bystander; check Cache Rules cacheability first. And if the split URLs are all DYNAMIC HTML, fix eligibility before key design.
Common mistakes
- Ignoring the query string zone-wide and breaking search and pagination in one move.
- Forgetting
gclidandfbclidafter carefully excludingutm_*. - Leaving
?v=cache busting in the build while the key ignores query strings. - Purging the bare URL and wondering why parameter variants persist — before normalization each variant is its own purge target.
- Normalizing at the edge while the origin cache behind it still keys on the full query string.
Prevention
Keep a documented exclusion list of tracking parameters and apply it to every zone you run. Fingerprint asset filenames so query strings never carry meaning for static files. Review cache analytics after each campaign launch — a MISS spike correlated with a new utm_campaign value means the list needs an update; the Cache Rules reference and rules language docs cover the matching syntax.
A cache split forty ways by marketing parameters is a cache in name only. Cache layers that fight each other cost real revenue — Stack Harbor tunes the whole stack, edge to origin, under Managed Cloud Ops; book an infrastructure review.