skip to content

In Cloudflare Cache Rules, what does the default cache key contain, and which Cache Key settings stop tracking parameters splitting the cache on each plan?

level: middleimportance: must knowfreq 55%

answer

  1. URL plus a few request headers
  2. every query string is its own entry
  3. ignore versus sort
  4. include and exclude lists are Enterprise
  5. origin scheme in the default key

basics

~20 s

The default key is the scheme, host, path and query string, plus the client's Origin header and a few override headers. Every plan can ignore or sort the query string; excluding single parameters, or keying on headers, cookies, host or user features, is Enterprise-only.

solid answer

~50 s

Cloudflare's default cache key is the full URL (scheme, host, path and query string), the client's `Origin` header, the method-override headers and a few host- and URL-override headers such as `x-forwarded-host`; cookies and `User-Agent` are not in it. Every distinct query string is a separate entry, so `utm_*` tags split one product page into many. In a Cache Rule's **Cache Key** setting, every plan gets **Ignore query string** (drop the whole query string) and **Sort query string** (only canonicalise parameter order), plus Cache Deception Armor and Cache by device type. Choosing which parameters to include or exclude, and adding headers, cookies, host or user features to the key, is **Enterprise-only**; a custom key can name up to 100 query parameters. In the default key the scheme is the origin scheme; in a custom key it is the visitor's.

go deeper

for a junior

Recall that the default key is the URL with its query string plus the Origin header, and that cookies are not in it.

for a middle

Explain Ignore query string versus Sort query string and which Cache Key parts are Enterprise-only, with the 100-parameter limit.

for a senior

Show how you would cut query-string fragmentation on a non-Enterprise zone without merging pages that differ by a parameter, and the purge cost of header or cookie keys.

for a principal

Weigh hit rate against correctness and plan cost: when an allowlist key justifies Enterprise, and when path-scoped rules are enough.

## What the default cache key holds A **cache key** is the identifier Cloudflare stores a response under; two requests with the same key share one cached copy. By default it is built from: 1. The **full URL**: the scheme, the host and the path with its query string, such as `/kettles?colour=blue&utm_source=mail`. 2. The **`Origin` request header** sent by the client, so responses for different cross-origin callers are not mixed. 3. The method-override headers `x-http-method-override`, `x-http-method` and `x-method-override`. 4. The host- and URL-override headers `x-forwarded-host`, `x-host`, `x-forwarded-scheme` (unless it is http or https), `x-original-url`, `x-rewrite-url` and `forwarded`. Cookies, `User-Agent` and `Accept-Language` are not part of it. In the default key the scheme is the **origin scheme**, the protocol Cloudflare uses to reach the origin. Moving the SSL/TLS encryption mode from Off or Flexible to Full, Full (strict) or Strict changes that scheme from HTTP to HTTPS, so every key changes and the cache effectively starts empty. In a custom key the scheme is the visitor's, and such a switch leaves keys alone. ## Why tracking parameters hurt Every distinct query string is a distinct entry. When campaign links add `utm_source`, `utm_campaign` or a referral ID, one product page becomes hundreds of entries. Each one is a miss the first time in each data center, so the hit rate falls and the origin carries load the cache should have absorbed. The aim is to take those parameters out of the key **without** dropping parameters that change the page, such as `?page=2` or `?size=m`. ## Cache Key settings by plan **Cache Key** is a setting inside a Cache Rule set to Eligible for cache (`cache_key` in the API). | Cache Key option | Free | Pro | Business | Enterprise | |---|---|---|---|---| | Cache deception armor | Yes | Yes | Yes | Yes | | Cache by device type | Yes | Yes | Yes | Yes | | Ignore query string | Yes | Yes | Yes | Yes | | Sort query string | Yes | Yes | Yes | Yes | | Query string include or exclude | No | No | No | Yes | | Headers, Cookie, Host, User features | No | No | No | Yes | Below Enterprise the query-string choice is therefore all or nothing: - **Ignore query string** drops the whole query string from the key. It is safe only on paths where no parameter changes the response, such as product images or a static landing page. - **Sort query string** (`ignore_query_strings_order`) only canonicalises order: `?a=1&b=2` and `?b=2&a=1` share an entry, but different values still split it, so it does nothing about `utm_source=mail` versus `utm_source=social`. On Enterprise the **Query string** section offers **All query string parameters**, **All query string parameters except** (an exclusion list such as `utm_source`, `utm_medium`, `utm_campaign`), **No query parameters except** (an allowlist such as `page` and `size`) and **Ignore query string**. A custom key can name at most **100** query string parameters. For a shop the allowlist is the sturdier choice: a new tracking parameter added by a marketing tool does not reopen the problem. ## The other custom key parts (Enterprise) - **Headers**: include a header's value, or only check that it is present. Restricted headers such as `accept`, `accept-language` and `user-agent` must be given explicit values. `cookie`, `host`, any `cf-` header and headers such as `range` or `if-none-match` cannot be added, and `Origin` is the only default header you can exclude. - **Cookie**: include a cookie's value or check for its presence; Cloudflare's own `__cf` cookies cannot be used. - **Host**: Use original host, or Resolved host, which follows an Origin Rule's DNS record override. - **User**: device type (mobile, desktop or tablet), country, and the first language in `Accept-Language`. Each part you add multiplies the entries per URL, so add one only when the response truly differs by it. Separately, a Cache Rule's **Vary** setting, on every plan, lets request headers that the origin lists in its `Vary` response join the key; how `Vary` itself works is covered with HTTP caching. ## Side effects to plan for - A custom key that includes headers or cookies stops dashboard single-file purge from finding the entry; clearing it then takes an API purge that sends the same values, or a broader purge method. - Prefetch always uses the default cache key, so it does not fill entries stored under a custom key. - With URL normalization on, also enable **Normalize URLs to origin** when you customise keys, so the URL in the key matches what the origin receives. - Cloudflare Trace shows, for a cached request, exactly which cache key properties were used.

  • On a Business zone, how would you stop utm tags splitting product pages without breaking ?page=2 listings?
    Below Enterprise the Cache Key cannot drop single parameters, so split by path. Give product detail pages and images a Cache Rule with Ignore query string, because no parameter changes them, and leave paginated listing pages on the full query string, accepting some splitting there. An Enterprise zone could instead use No query parameters except with `page` and `size`.
  • Why does switching from Flexible to Full (strict) cause a burst of cache misses on a zone with default keys but not with a custom key?
    The default key holds the origin scheme, and Full (strict) makes Cloudflare reach the origin over HTTPS instead of HTTP, so every key changes and nothing already stored matches. A custom key holds the visitor's scheme instead, which the encryption mode does not change, so existing entries keep matching.

  • Sort query string removes tracking parameters such as utm_source from the cache key.
  • Any plan can exclude single query parameters from the key in a Cache Rule.
  • Cloudflare's default cache key includes cookies, so each signed-in user gets a separate copy.
  • Adding the session cookie to the cache key costs nothing in hit rate.
  • Ignore query string is always safe because the origin reads parameters anyway.

Assumes Cloudflare as of 2026-10-10: Ignore query string and Sort query string are on every plan while the other custom key parts stay Enterprise-only, and since July 2026 a Cache Rule's Vary setting, on every plan, can add the headers an origin lists in Vary to the key.