On this page
A CDN query string cache key determines which requests can reuse the same stored response. Before changing it, check both sides of the decision: functional parameters must produce separate variants when they change the response, while tracking parameters can share a variant only when they do not affect the response.
This workflow uses an illustrative staging test. It was not executed here, and no CDN provider documentation was available to consult. Before applying the workflow, check your provider’s current official documentation for cache-key, query-forwarding, purge, and cache-status behavior.
Key Takeaways
- A cache key and the request forwarded to the origin are separate concerns. Verify both.
- Omitting a functional parameter from the key can serve the wrong variant; omitting a user-specific parameter can expose one user’s response to another.
- Ignoring a tracking parameter is safe only if it cannot change the cacheable response, including relevant headers.
- Test distinct functional values and tracking-only changes in an isolated environment, using origin observations as well as CDN diagnostics.
Decide which requests may share a response
A CDN can use the full query string in its cache key, exclude some or all parameters, or normalize the query before constructing the key. Normalization might, for example, make different parameter orders equivalent. The exact options and their effects depend on the provider and configuration.
The origin application has its own parameter handling. A CDN might distinguish two requests in its key but forward both unchanged, or it might use a reduced key while still forwarding parameters to the origin. Do not assume that a parameter excluded from the key is also removed from the origin request, or vice versa.
For each parameter, ask:
- Can it change the response body, status, redirects, or cache-relevant headers?
- Can it select a user, tenant, authorization context, or private resource?
- If it is omitted from the key, what happens when it is still forwarded to the origin?
A parameter that selects currency, language, format, or a resource generally needs to distinguish cache entries when it changes the response. A tracking parameter may be excluded only after confirming that neither the application nor any intermediary uses it to change the cacheable response.
Advertisement
Build an illustrative test matrix
Use a staging hostname and a cacheable endpoint you control. The following fictional requests all use the same path. Assume the origin displays prices according to currency and does not use utm_source to change the response.
| Request | URL | Intended relationship |
|---|---|---|
| A: baseline | https://cache-test.example.test/catalog?currency=USD&utm_source=alpha | Establish the USD variant. |
| B: functional change | https://cache-test.example.test/catalog?currency=EUR&utm_source=alpha | Must not reuse the USD response if currency changes it. |
| C: tracking-only change | https://cache-test.example.test/catalog?currency=USD&utm_source=beta | May reuse A only if the tracking value does not affect the response. |
These are expected relationships, not observed test results. Before testing the CDN, request the endpoint directly from the origin through an approved staging route. Confirm that A and B actually differ in the intended way and that A and C are equivalent for caching. Compare status, body, redirects, and relevant headers—not just one visible field. Ensure the origin route is not exposed merely for this test.
If the application reflects utm_source into HTML, changes a cookie, selects an experiment, or redirects based on it, A and C may not be interchangeable. Either retain the necessary distinction, change the application behavior, or avoid shared caching for that response.
Run the staging diagnostic
- Isolate the experiment. Use synthetic data and a staging cache namespace or a provider-supported purge of the relevant entries. Confirm the endpoint is eligible for shared caching and that the test does not affect production traffic.
- Keep other key inputs constant. Use the same method, hostname, path, relevant headers, cookies, and client location for the comparison. Check whether the CDN configuration keys on any of these inputs too.
- Establish A. Send A, then repeat it while the entry should still be fresh. Record the response and available CDN cache-status information. Use origin logs or a staging-only origin counter to see whether the origin was contacted.
- Check B. Send B, then repeat it. Confirm that B returns the EUR response rather than A’s USD response. If B should be cached separately, look for evidence of a distinct fill followed by reuse.
- Check C. Send C after A is warm. If the desired policy ignores
utm_source, check whether C can reuse A and still returns the correct response. If it reaches the origin, investigate whether the tracking value remains in the key or another key input differs. - Inspect origin requests. On cache fills, record which query parameters the origin actually receives. A cache hit normally does not provide a new origin request to inspect, so use separate controlled misses when checking forwarding behavior.
- Repeat after the proposed change. Compare the response correctness, forwarding observations, and available cache diagnostics before and after. Roll back or block deployment if a functional or private variant crosses its intended boundary.
A cache-status header or Age value can help, but neither alone proves that the intended key was used. Caches can be distributed across locations, entries can expire or be evicted, and other policies can bypass or revalidate a response. Use the provider’s documented diagnostics and correlate them with controlled origin observations. Remove or restrict any staging debug headers and logs when the test is complete.
Advertisement
Check normalization and privacy boundaries
Add cases for the forms your clients actually send: reordered parameters, repeated names, empty values, missing parameters, and differently encoded values. Do not assume these forms are equivalent. For example, an origin may interpret repeated parameters differently from the CDN’s normalization rule. If two requests map to one key but the origin treats them differently, the first fill can determine the response served to the other request.
Treat user-specific query values as sensitive. If a response depends on a user, tenant, token, or authorization context, a shared cache entry can serve private content to the wrong requester when that distinction is omitted or incorrectly normalized. A tracking parameter can also become a cache-poisoning input if it is excluded from the key but the origin reflects it into a shared response.
Prefer not to place secrets in URLs: query strings can appear in logs and other records. For authenticated or personalized responses, use an explicitly reviewed cache policy and access-control design; bypassing shared caching is often the safer starting point. Adding a user identifier to a cache key alone is not a complete privacy or authorization control.
Common Mistakes
- Counting variants without checking content. Separate entries are not useful if the origin receives the wrong parameters or produces the wrong response.
- Assuming excluded parameters disappear. An omitted key component may still reach the origin and change the response used to fill a shared entry.
- Testing only cold requests. Repeated requests are needed to investigate reuse, though a miss can have causes other than the key.
- Treating all tracking parameters as harmless. Application code, experiments, redirects, or cookies may make them response-dependent.
- Ignoring non-query inputs. Cookies, headers, hostname, method, and cache rules may also distinguish or bypass entries.
Best Practices
Document each response-affecting parameter and its intended cache treatment alongside the origin’s interpretation. Verify provider-specific configuration and normalization behavior against current official documentation before deployment. Test representative edge cases in staging, monitor for incorrect variants after rollout, and keep a rollback path for the cache policy change.
Conclusion
A safe cache-key change starts with an explicit equivalence decision: which requests are allowed to receive the same response? Verify that decision against both the CDN’s behavior and the origin’s actual parameter handling before deploying.
What would your domain sell for?
A free TidyURLs account unlocks the Domain Estimator. It prices a name from 191,011 real domain sales.