Controlling query-string caching without mixing different content

A cache key decides which requests share one cached response. Query parameters can identify different content, so ignore them only when the application truly returns the same public resource.

What you need before you begin

List the parameters used for search, pagination, language, currency, authorisation and asset versioning. Confirm which controls your Cloudflare plan exposes before designing a custom key.

01 Control query-string caching without mixing different content

  1. Choose a narrow public path for the proposed Cache Rule and inspect responses for several parameter values.
  2. Keep parameters that change content or access rights in the key, or bypass caching for those requests.
  3. Use available query-string key settings only for parameters proven irrelevant, such as a specific tracking parameter on an otherwise identical public asset.
  4. Test different parameter combinations and compare both content and cache status from separate sessions. Include duplicate or reordered parameters if the application treats their order specially.
  5. Document the key design and purge affected objects appropriately when changing it. Review any purge tooling that assumes a simple URL-only key.

02 Example: classify query parameters before changing a cache key

Before ignoring query strings, compare actual responses for the same public path. These fictional examples demonstrate why parameters that change content need different treatment from a verified tracking-only value. They are review notes, not settings to paste into a rule.

Code or configuration example
/shop/?currency=NGN versus /shop/?currency=USD
  Different prices or presentation: retain the variant or bypass.
/search/?q=backup versus /search/?q=email
  Different results: do not merge into one cached response.
/assets/site.8a41c2ef.css?utm_source=newsletter
  Consider ignoring only after proving the public file is identical.

Also identify signed-download tokens and version parameters. Removing a token from a key can break access separation, while ignoring a version parameter can preserve stale assets. Custom cache-key options depend on the available Cloudflare plan and rule controls.

Expected result: Only proven equivalent public requests share an entry. Different languages, currencies, search results and private downloads retain the separation needed for correct content and access.

Confirm the expected result

Different content variants should remain separate, while safe equivalent public requests may share a cache entry. Verify privacy and functional correctness before measuring the hit-rate improvement.

Troubleshoot unexpected results

Ignoring a signed download token, search query or language parameter can return the wrong content or expose protected data. Query-string sorting is also unsafe for applications where order has meaning. Custom-key options vary by plan.

Can I ignore a cache-busting version parameter?

Only if you replace that update mechanism. Otherwise old and new asset versions may share the same edge entry, defeating the reason the application added the parameter.

Sources and further reading

  • 0 Users Found This Useful
  • performance
Was this answer helpful?

Related Articles

Using Cloudflare Always Online for limited outage fallback

Always Online can provide limited cached or archived public content when the origin is...

Distinguishing browser cache lifetime from edge cache lifetime

Browser cache lifetime and Cloudflare edge lifetime control different copies of a resource....

Bypassing cache for private account and checkout pages

Private account, cart and checkout responses must not be shared between visitors. Use explicit...

Checking why cookies prevent or alter Cloudflare caching

Cookies influence application state, but the presence of a request cookie does not universally...

Creating a cache rule for public static assets

A cache rule can make a known public asset path eligible for edge caching. Scope the rule to...