Cloudflare Custom Cache Key: A Guide for Website Owners
Learn how Cloudflare’s Custom Cache Key uses every query-string parameter to separate cached versions, with the documented Cache Rules setup.
Facts that can change should include a source and check date. Benchmark claims should state the plan, region, method, and test period.
When a Custom Cache Key helps#
If a Cloudflare-cached response can change based on URL query parameters, Cloudflare’s documented Custom Cache Key rule keeps those parameter combinations distinct. The example matches hostnames containing example.com, sets Cache eligibility to Eligible for cache, and sets Cache key → Query string to All query string parameters. In this configuration, Cloudflare includes every query-string parameter when identifying the cached version of a request.
This behavior is specific to Cloudflare Cache Rules. Other hosting or CDN products may use different names, controls, or defaults.
What “all query string parameters” means#
A URL can have a path and a query string, such as /products?color=blue&view=grid. With this setting, the query-string parameters and their values are part of cache identification. A request with a different parameter or value is treated as a different cached version under this rule. The setting does not rewrite the URL or change the response; it tells Cloudflare which request details to use when identifying a cached object.
Cloudflare’s documented configuration#
Cloudflare’s Custom Cache Key example uses a Cache Rule with these choices:
| Rule part | Documented choice |
|---|---|
| Match | Hostnames containing example.com |
| Cache eligibility | Eligible for cache |
| Cache key — Query string | All query string parameters |
The hostname match determines which requests the rule addresses. Cache eligibility and cache-key selection are separate parts of the example: the first marks matching requests as eligible for caching, while the second defines how query strings contribute to the cache key.
Before choosing this setting#
Check whether every query parameter can change the content or response for the page. If so, including all parameters keeps those request variants separate under the documented configuration. If some parameters are used only for measurement or navigation and do not change the content, including them can create separate cache-key variants for requests that would otherwise return the same content.
Review the hostname expression before applying the rule so it covers only the intended site. The documented example is a Cloudflare-specific configuration, not a general instruction for every hosting provider.
For broader context, consult Cloudflare’s cache documentation alongside the Custom Cache Key example.
Sources
- Cloudflare: Custom Cache Key Checked 2026-11-20
- Cloudflare cache documentation Checked 2026-11-20