Course contentsShow
← Cloud and Infrastructure
Lesson 598 of 2,98911. CDN and Edge ComputingFree lesson

Query String and Cookie Forwarding

Control which query parameters and cookies are forwarded to origins and affect cache keys.

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=1 and image.jpg?v=2 are treated as different requests
  • Forward none → both requests fetch the same cached image.jpg
  • Forward specific parameters → only meaningful ones (like size or format) 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_id but not analytics_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.