An encoding cache audit checks whether each request receives a representation it can decode, even after another client has warmed the same URL. Test the response body, negotiation headers and reuse behavior together before changing cache keys. A faster cache hit is useful only when it returns the right bytes.
Separate negotiation from cache eligibility
Accept-Encoding describes the content codings a client accepts. Content-Encoding describes the coding applied to the returned representation. Vary: Accept-Encoding tells a cache that this request header participated in selecting the response. These fields solve different problems; adding Vary does not enable compression or make a private response suitable for shared storage.
The HTTP caching rules for Vary matching define how a cache compares a new request with the request behind a stored response. A matching variant still needs permission for reuse under the response's cache policy. Keep that distinction visible in your test notes: selection answers which object, while freshness and storage directives answer whether the object may be reused.
Begin with one public, versioned text asset you control, such as a stylesheet. Keep its bytes unchanged throughout the experiment. Avoid account pages, changing API responses and production customer data. Record the intended content type and a checksum of the uncompressed source file so that a successful status code cannot hide an incorrect body.
Write down which layer performs compression: the application, reverse proxy, CDN or a combination. An edge may fetch one representation from the origin and transform it for downstream clients. That can be legitimate, but the audit must observe both sides separately. The browser caching guide provides the broader storage and validation background.
Build a small negotiation matrix
Use deliberate request values rather than copying a single browser's default. Include an explicitly uncompressed request, a supported compressed request, an exclusion and an absent header. Do not interpret an absent Accept-Encoding field as an explicit request for identity: HTTP permits any content coding when the field is missing. An empty field has different semantics and requests no content coding.
| Request value | What the test establishes |
|---|---|
identity |
The response is usable without a content coding |
gzip |
A gzip-capable client gets an acceptable representation |
br, gzip |
The server can choose among advertised codings |
gzip;q=0, identity;q=1 |
A forbidden coding is not selected |
| Header absent | Behavior follows the documented negotiation policy |
| Empty field | The no-content-coding case is handled separately |
Advertising gzip does not necessarily force a gzip response: identity can remain acceptable. Similarly, advertising Brotli is not proof that this deployment supports it. Judge correctness against the client's acceptable set and the server's documented policy, then evaluate whether the chosen compression meets your performance goal.
Test quality values deliberately. A normalizer that simply searches for the substring gzip could wrongly treat gzip;q=0 as permission. Use a parser or established proxy feature with documented semantics. Unknown codings and changed ordering deserve separate cases if your configuration claims to normalize them. Do not invent expected results for an unsupported feature.
Capture bodies as well as headers
Issue GET requests to the same exact URL, saving response headers and bodies separately. HEAD alone cannot establish that the returned bytes match Content-Encoding. Keep the request method, host, path, query string and other headers constant while varying the encoding input. Otherwise you may accidentally test several cache keys at once.
For a raw-body check, send the desired Accept-Encoding header explicitly and avoid automatic content decoding in the client. For a browser-like decoding check, use a client mode that negotiates supported compression and decodes it, such as curl's --compressed option. Record which mode produced each file; a decoded output file can differ from the encoded transfer even when the saved headers still describe that transfer.
For each response, record the status, Content-Encoding, Vary, Cache-Control, validator and any documented cache-status field. Record the observed body length and, after correct decoding, its checksum. Compare the decoded result with the fixed source. Do not compare gzip and identity wire checksums and call their expected difference corruption.
If decoding fails, stop the reuse experiment and locate the first layer where header and body disagree. Common diagnostic possibilities include compressed bytes without a coding header, a coding header attached to plain bytes, or a transformation applied twice. These are hypotheses to test, not a claim that every proxy suffers these defects.
Reverse the cache warming order
A cold request succeeding proves little about variant isolation. Warm the asset with a gzip-capable request, repeat it, then request identity. Next use a fresh controlled test object or invalidate only this asset and reverse the sequence. Compare the decoded payload after every step. Repeat for Brotli when the deployment actually supports it.
Use the same URL within each sequence. Adding a random query parameter to every request can guarantee misses and conceal the bug you are looking for. If you use different versioned URLs to isolate experiments, ensure they pass through identical cache and compression rules. Keep a record of each test object's lifecycle.
Do not treat the first repeated request as a guaranteed hit. A cache may decline storage, evict the object, route the next request to another node or revalidate it. Use documented diagnostics or logs to establish the actual path. An Age value can provide supporting evidence, but a missing or zero value alone does not establish a miss.
Run the matrix against the origin path and the public edge path where your access permits it. If the origin is correct and only the edge changes results, investigate that boundary. Preserve host and TLS routing when reaching an authorized origin directly. A different virtual host is a different experiment and may use unrelated rules.
Normalize only equivalent request meaning
Raw request strings can produce more cache variants than the application needs. Extra variants consume storage and split traffic across objects that warm separately. However, collapsing every string into a broad yes-or-no flag can merge clients with different accepted codings. The useful target is a small set of correctly selected representations, not the smallest possible key.
Document both the incoming value and the effective value used between the edge and origin. A managed cache may normalize encoding automatically, retain an internal representation and compress later, or support only particular Vary fields. There is no portable configuration switch that makes all implementations behave identically. Verify the actual product documentation before adding custom key logic.
Change one normalization rule at a time. Include exclusions, preferences and the empty-header case in the regression set. Where you deliberately map equivalent inputs to the same representation, verify both directions of the warming test. A good result for the common browser header does not establish correctness for the other accepted request forms.
Track variant count beside origin request volume and the cache hit denominator. A higher aggregate hit ratio can conceal one broken minority variant. Segment failures and response sizes by selected encoding. Compare equivalent traffic periods before drawing performance conclusions; do not attribute every change in TTFB to a smaller key.
Keep validation consistent across variants
Check both full responses and conditional requests. A 304 Not Modified has no replacement representation body, so the client depends on its existing cached copy and the returned metadata. The negotiation contract must remain consistent when validation takes place, including the appropriate Vary value. Also inspect error and fallback responses for accidental policy changes.
Capture a validator from a particular variant and revalidate that same variant first. Then test a different encoding with the earlier validator and inspect the result against HTTP semantics and your implementation's validator design. Do not assume that every representation must share an ETag merely because decoding produces the same text. Strong validators identify representation data, including content coding differences.
If a transformation changes representation bytes, establish which layer owns the validator and how it adjusts or weakens it. Do not manufacture a strong ETag by copying an origin value onto a different encoded representation. Keep tests for freshness, validation and byte ranges separate enough that one mechanism cannot mask a failure in another.
Protect personalized responses independently
Encoding separation is not user separation. Vary: Accept-Encoding cannot distinguish two customers whose sessions produce different account details. Adding the whole Cookie field to the key can create enormous numbers of variants and still does not replace an explicit policy for authenticated content. Review those routes independently from the public asset experiment.
Use the application's intended private or non-storage policy and the shared-cache bypass rules appropriate to the endpoint. Test with synthetic accounts whose harmless fixture content differs clearly. Request as account A, account B and an anonymous client in different orders, confirming that each receives only its intended content. Keep credentials out of shared logs and test reports.
Do not weaken privacy controls to improve a hit ratio. If a public shell and private data are intentionally separated, prove that the shell contains no account-specific material before sharing it. The CDN and edge caching guide explains the surrounding eligibility and purge decisions.
Release with a repeatable acceptance record
Save the request matrix, expected acceptable codings, decoding checks, warming order and layer diagnostics with the configuration change. A useful acceptance record shows correct payloads for cold, warm and revalidated requests, plus the separate privacy checks. Keep it small enough to rerun after a proxy update or compression change.
Roll out to a limited public asset class first. Watch decoding errors, selected encoding, origin load and transfer sizes together. Retain the previous configuration and a targeted invalidation procedure, since changing a header does not automatically remove every object stored under an earlier key. Expand the change only after correctness survives the repeated sequence, then assess the measured performance benefit.