On this page
CDN image URL query parameters can request smaller dimensions, a different quality level, or another image format. They can also create separate cached versions of the same source image. For an ecommerce site with many products and storefront templates, inconsistent URL generation can multiply those variants and reduce cache reuse.
This guide explains the interaction and gives you a way to test it. Parameter names and cache behavior are provider-specific; the examples below illustrate concepts, not a particular CDN's API. Provider documentation was not retrieved for this article, so check your provider's current documentation before implementing a transformation or cache-key rule.
Key Takeaways
- Transformation parameters affect the returned image only if your image service recognizes and processes them.
- Whether a query string distinguishes cache entries depends on the CDN's cache-key configuration. Some parameters may be ignored, normalized, or included.
- Use a small, intentional set of image variants to improve reuse without sacrificing required display quality.
- Test the response body, content type, fallback behavior, and cache signals—not just the URL or HTTP status.
- If the response format depends on the
Acceptheader, the cache must distinguish the relevant negotiated formats.
What image transformation parameters do
An image service may offer controls such as:
| Transformation | Typical purpose | Trade-off |
|---|---|---|
| Width | Resize an image for a display size or device density | Too small can look blurry; too many widths create more variants. |
| Quality | Adjust an encoder's quality setting | Lower values may reduce transfer size but introduce visible artifacts. Scales and defaults vary by provider and format. |
| Format | Request or negotiate a format such as JPEG, WebP, or AVIF | Browser support, encoding behavior, transparency, and animation support vary. |
For example, a URL might conceptually contain width=400, quality=75, and a format instruction. Those names and values are not a portable CDN API. One service may use different names, accept transformations in the path, restrict allowed values, or require configuration before processing them. Some services do not transform images at all.
Choose output widths based on actual rendered sizes and device pixel ratios. A product card displayed at 200 CSS pixels may benefit from a roughly 400-pixel image on a 2x-density screen, subject to the source image's dimensions and your service's upscaling rules. Avoid requesting a large source for every thumbnail, but check visual quality before reducing it.
Advertisement
How query parameters affect CDN cache keys
A cache key identifies the stored response a CDN can reuse. Depending on configuration, the key can include the URL path, all or selected query parameters, and selected request headers or other attributes. The exact defaults and controls differ between CDNs and sometimes between features within a provider.
Consider these illustrative URLs; the parameter syntax is not tied to a provider:
https://images.example.com/products/shoe.jpg?width=400&quality=75
https://images.example.com/products/shoe.jpg?width=401&quality=75
https://images.example.com/products/shoe.jpg?quality=75&width=400
If width and quality are part of the key, the first two requests may create distinct cached objects. The third requests the same conceptual values as the first, but parameter ordering could still matter unless the CDN normalizes it. Even if two requests produce identical bytes, they may occupy separate cache entries.
Fragmentation grows with the combinations requested: five widths, three quality settings, and two explicit formats can represent up to 30 variants for one source image, before accounting for other key dimensions. Actual storage and cache reuse depend on which variants are requested, cache policy, eviction, and CDN architecture.
The opposite configuration can also be wrong. If a transformation parameter changes the response but is omitted from the cache key, one variant might be served in response to a request for another. Do not remove parameters from the key merely to improve hit rates: first establish which parameters affect the response, authorization, or routing.
Standardize variants at the source
Define a short list of supported widths and quality settings for each image use case, such as product cards and detail views. Generate URLs through one shared function or component so equivalent requests use the same parameter names, ordering, and defaults.
Review unrelated query parameters too. Analytics tags or arbitrary cache-busting values can split cache entries if included in the key. Exclude a parameter only after verifying that it does not affect the image, access control, or another response property. If URLs are signed, follow your provider's signing and cache-key guidance: changing, reordering, or dropping parameters can invalidate a signature or create a security issue.
For updated product images, decide whether to use versioned URLs or invalidation. A version parameter that changes on every request defeats reuse; one that changes only when the source changes can be a deliberate way to avoid stale content. Confirm how your provider caches and invalidates transformed derivatives.
Format negotiation and fallbacks
Some image services can choose a format based on the request's Accept header instead of requiring an explicit format in the URL. If different clients can receive different bytes at the same URL, cache configuration must account for that difference. A Vary: Accept response header signals the distinction to HTTP caches, but confirm how your CDN implements variation and constructs its own cache key; do not assume the header alone configures every CDN feature.
Explicit format URLs can make variants easier to reason about, but the application must select a compatible format or provide a fallback. With automatic negotiation, test clients that advertise different capabilities and one that does not advertise a modern format. Check the returned Content-Type and actual file format. Also verify transparency, animation, orientation, and visual quality where they matter to your catalog.
A failed transformation might return an error, the original image, or another fallback, depending on the service. A 200 response alone does not prove the requested transformation happened. Check whether errors or fallbacks are cached and how long they remain visible after the underlying issue is fixed.
Advertisement
Test transformations and cache behavior
Use a non-sensitive image and a URL generated according to your provider's documentation. Run these checks against a staging environment or a resource you are authorized to test. The commands require curl and the file utility. Set URL to your own valid transformed image URL before running them:
URL='https://images.example.com/replace-with-your-valid-image-url'
curl -sS -L -D first-headers.txt -o first-image \
-w 'First response: %{http_code}\n' "$URL"
curl -sS -L -D second-headers.txt -o second-image \
-w 'Second response: %{http_code}\n' "$URL"
file first-image second-image
cat first-headers.txt
cat second-headers.txt
Replace the example URL; it is not a working provider endpoint. Because -L follows redirects, the header files can contain multiple response blocks. Inspect the final response as well as any redirects. The file output can help identify the format, but use an image inspection tool to check pixel dimensions and examine the image visually too.
Use this checklist:
- Transformation: Request each supported width and quality setting. Check dimensions, format, file size, and visual quality against the intended display. Include an image smaller than the requested width and images with transparency or animation if relevant.
- Fallbacks and errors: Try an unsupported format or invalid parameter in a safe environment. Record the status, body, content type, and any fallback. Confirm how long an error or fallback can be cached.
- Cache reuse: Repeat the same request and inspect provider-documented cache-status headers,
Age, andCache-Controlwhere present. A second request is not guaranteed to be a hit: cache layers, expiration, routing, and configuration can affect the result. Interpret signals using your provider's documentation. - Key differences: Compare supported widths and formats, then try equivalent URLs with reordered parameters and an unrelated parameter. Determine whether each produces the expected image and whether the provider reports separate cache behavior. Do not assume query ordering is normalized.
- Negotiation: If format selection uses
Accept, repeat requests with different supportedAcceptheaders and inspect both content type and image bytes. Confirm that one client's cached format is not incorrectly served to another. - Updates: Change a test source image and exercise your versioning or invalidation process. Verify when both the original and transformed variants reflect the update.
Headers can provide evidence of caching, but they may be absent or describe only one layer. Use your CDN's documented diagnostics and logs when available; do not infer a universal hit or miss solely from a missing Age header.
Common Mistakes
- Assuming universal syntax. A parameter copied from another CDN may be ignored, rejected, or interpreted differently.
- Ignoring parameters that change output. An overly broad cache-key exclusion can return the wrong size or format.
- Generating nearly identical variants. Uncontrolled widths and arbitrary quality values make reuse harder.
- Checking only status codes. A successful response may still contain an untransformed original or an unexpected format.
- Overlooking negotiation. A cache that does not distinguish relevant
Acceptvalues can serve an incompatible representation. - Treating signed URLs like public URLs. Cache-key changes must preserve the provider's authentication and authorization model.
Best Practices
Document a variant policy for each storefront component, centralize URL generation, and measure actual requested variants before changing cache rules. Bound the widths, quality settings, and source images that clients may request where your service supports it; unrestricted transformations can consume resources and generate excessive variants. Keep private images behind appropriate authorization, and avoid putting secrets or personal data in URLs that may appear in logs or caches.
Recheck your provider's documentation and deployment configuration whenever you change transformation settings, cache keys, format negotiation, or invalidation behavior.
Conclusion
Image transformation URLs and CDN cache keys need to be designed together. Standardize the variants your storefront actually needs, ensure every response-changing input is handled safely by the cache, and verify the resulting images and cache behavior in your own environment.
What would your domain sell for?
A free TidyURLs account unlocks the Domain Estimator. It prices a name from 191,011 real domain sales.