Query String and Cookie Forwarding
What You'll Learn
You'll learn how to control which URL query parameters and cookies are sent to your origin servers and how they affect CDN cache behavior.
The Core Concept
When a user requests content through a CDN, the URL may contain query strings (like ?user=john&theme=dark) and the browser may send cookies along with the request. By default, CDNs must decide: should these be forwarded to the origin server? Should different query strings or cookies create separate cached versions?
Query String Forwarding determines which parameters are passed to your origin. For example:
- Forward all query strings →
image.jpg?v=1andimage.jpg?v=2are treated as different requests - Forward none → both requests fetch the same cached
image.jpg - Forward specific parameters → only meaningful ones (like
sizeorformat) affect caching
Cookie Forwarding works similarly. You can:
- Forward all cookies to the origin (needed for personalized content)
- Forward none (for fully static assets)
- Whitelist specific cookies (like
session_idbut notanalytics_token)
Why This Matters
Each unique combination of forwarded query strings and cookies creates a separate cache entry. Too permissive forwarding can fragment your cache, reducing hit rates and effectiveness. Too restrictive forwarding might break functionality if your origin needs those values.
Think of it like a library catalog: If every tiny annotation creates a new catalog entry, you'll have countless duplicates. But if you ignore important differences, patrons get the wrong book version.
Key Takeaway
Configure query string and cookie forwarding to balance cache efficiency with application functionality—forward only what your origin needs and what should create distinct cached versions.