Skip to content

CloudFront serves the wrong variant for a query URL

Check whether CloudFront forwards and caches the query parameters that select public content, then verify distinct variants without caching private state.

By Crawlito · 5 min read

In short

  • Forwarding a query parameter and including it in the cache key are different decisions.
  • A content-changing parameter needs a deliberate cache policy.
  • Test variants in both request orders to expose one cached response being reused incorrectly.
On this page

If two public query URLs show the same product variant or language through CloudFront, inspect both query forwarding and the cache key. The origin may need the parameter to choose content, and the cache must distinguish responses that genuinely differ. Repair that contract and test the variants in both request orders before changing canonical tags.

A correct origin response alone does not clear the CDN. The first response cached under an overly broad key can be reused for a later request that meant something else.

Define which parameter changes the content

List the actual public parameter and the response difference it controls. For example, a color selector may change the product image and selected item, while a campaign parameter only records acquisition context.

Do not include every query parameter in the cache key without a reason. Tracking values can create many redundant entries for identical public content.

AWS's query-string caching guide explains forwarding and caching choices for query parameters. Your policy should reflect the origin's actual behavior.

Write a small contract:

color=red: public red variant
color=blue: public blue variant
utm_source: no change to the public product representation
account-specific state: handled by a separate private response policy

These are illustrative values. Use the site's actual parameter names and supported content states.

The URL parameter guide helps separate content selection from tracking before the infrastructure policy is changed.

Compare the public responses in both orders

Choose two known variants and fetch them without an authenticated session:

bash
curl -sS -D red-headers.txt -o red.html \
  'https://www.example.com/product/shirt?color=red'
curl -sS -D blue-headers.txt -o blue.html \
  'https://www.example.com/product/shirt?color=blue'

Inspect the selected variant and a distinctive body or data marker. Do not rely only on a title shared by every variant.

In a controlled test environment or after an appropriate scoped cache reset, reverse the request order. If whichever variant is requested first appears for both URLs, the cache key is a strong suspect.

Do not continuously purge production to run experiments. Use the smallest authorized sample and preserve the evidence from each sequence.

Record status, relevant cache headers, requested URL, and observed variant. That makes the behavior reproducible for the infrastructure owner.

Check forwarding and cache identity separately

Inspect the cache policy and the origin request policy associated with the matched behavior. Determine which query parameters reach the origin and which participate in cache identity.

A parameter can reach the origin without separating cached responses. That combination is important when the origin returns different public content for different values.

Conversely, a parameter included in the cache key but ignored by the origin can waste cache capacity without improving correctness.

Confirm the origin's actual response for each intended value through an authorized path. A faulty origin selector can look like a CDN defect.

The product variant guide helps verify the selected offer itself. The correct cache policy cannot repair an origin that always chooses the default item.

Keep user-specific and public variation separate. Do not add a private session token to a public cache key as a casual fix for personalized content.

Repair the smallest relevant behavior

Update the supported policy for the route family that needs the content-changing parameter. Preserve a clear contract for unrelated paths.

If several parameters jointly select a public representation, include the necessary set and validate their handling. Do not assume only the first query parameter matters.

Review parameter spelling, case, ordering, and normalization according to the application's supported URL format. Keep generated links consistent so equivalent requests do not create needless variation.

For tracking parameters, decide whether they need forwarding for a legitimate origin function without changing the public representation. Make that a separate policy decision from variant identity.

If the response contains private account information, revisit the caching design rather than treating it as another public variant. The article's diagnostic example assumes public product or language content.

Document the changed behavior, parameter set, and expected response markers so a future cache-policy refactor preserves the distinction.

Clear stale entries deliberately and verify again

A policy correction may coexist with previously cached responses during rollout. Follow the platform's supported deployment and invalidation process for the affected paths.

Then repeat the two-variant sequence in both orders. Confirm that the correct public item or language appears consistently.

Check the initial HTML and rendered page separately if client-side code also changes the selection. A browser can visually repair a wrong cached shell while a plain reader still receives the default variant.

The raw and rendered HTML guide explains why both observations belong in the acceptance record.

Do not stop at different file hashes. Dynamic request identifiers can make two wrong pages differ at the byte level. Compare the actual content facts that the parameter is meant to select.

Reconcile canonical and structured-data output

After delivery is correct, inspect each page's canonical policy and product data. The cache repair should not accidentally make the red URL claim the blue offer or return another language's metadata.

Decide canonical relationships from the site's content strategy and supported platform behavior, not from the accidental response that was cached first.

Check sitemap and internal links for the intended public destinations. A cache fix does not decide whether every variant URL belongs in discovery.

Use a concise matrix:

Requested stateVisible selectionInitial responseStructured data
First variantCorrect itemCorrect public factsMatching offer
Second variantCorrect itemCorrect public factsMatching offer
Tracking-only changeSame contentSame public factsSame intended identity

This connects the infrastructure change to what readers and crawlers actually receive.

Protect the contract in future releases

Keep the two-variant test when changing cache policies, storefront routing, or product selection logic. Those are the changes most likely to alter the response relationship.

For an agency handoff, include the old and new policy behavior rather than a vague instruction to “clear the cache.” The durable repair is the distinction between content states.

Test a default URL with no selector and an unsupported value. The application should have deliberate behavior for both, rather than reusing an arbitrary cached variant.

Also inspect a route outside the changed behavior. A scoped repair should not create unnecessary query variation across the entire site.

Monitor real outcomes separately. Correct variant delivery helps readers reach the item they requested, but it does not establish a ranking or sales increase without measurement.

Include default and empty parameter values in the test set. For example, decide whether an omitted language value and an explicit default language should represent the same public content. Then document how an unknown value is handled. A fallback may be acceptable, but it should be consistent between the origin, edge response, and page metadata.

Do not use this public-variant repair as a reason to place personalized state in a shared cache. If a page also depends on an authenticated session or private account context, review that delivery contract separately. The successful language comparison proves only that the tested public variants remain distinct; it does not prove that every other cache input is safe.

Frequently asked questions

Is forwarding the parameter enough?

Not when cached responses vary by that parameter and the cache key ignores it. Inspect both decisions.

Should every tracking parameter enter the cache key?

Only when it genuinely changes the representation and the design calls for it. Avoid redundant public cache entries.

Can a browser selector hide the problem?

Yes. Client-side code may change what the visitor sees after the initial response. Inspect the original HTML too.

Run a representative public variant URL through the free Crawlito check after the cache contract is corrected.

Filed under Platform guides. Topics: caching, url-parameters, ecommerce