top of page

Can a Shared Cache Serve the Wrong Language for the Same URL?

Oct 24
3 min read
Vary Headers: Keep Cached Language Versions Distinct: Identify representation inputs; Test both request orders; Inspect cached response identity.

The same resource URL returns English text to one request and French text to another. After caching is enabled, some visitors receive whichever language was requested first. The origin's language selection may be correct while the cache's representation selection is incomplete.


When a response changes according to request headers, the cache needs enough information to distinguish the relevant variants.


Map what selects the representation


Write down every input that can affect the response: URL, query parameters, relevant headers and any other application context. Distinguish representation selection from authorization and user-specific content.


For a public language-negotiated response, the language preference header may be relevant. For content with explicit language in the URL, a different design may already distinguish representations. Review the actual application instead of adding a header mechanically.


Example: one public help resource


Consider an illustrative public help endpoint that selects English or French based on Accept-Language. Use two controlled requests with different language preferences and confirm the origin returns the intended version.


Then route the same requests through the cache. The test must verify the returned language, not merely a successful status code.


Understand the role of Vary


RFC 9111's cache-key section explains that, for a stored response with Vary, the nominated request headers must match the original request before reuse without revalidation.


This provides a protocol rule for selecting stored representations. It does not replace the rest of the caching policy, and it is not an access-control mechanism.


Keep sensitive content out of this shortcut


Do not assume that adding a user-related header to Vary makes personalized content safe for shared caching. Review whether the response should be stored by a shared cache at all.


Use the application's documented privacy and authentication requirements to make that decision. Language correctness and protection of private records are separate acceptance concerns.


Test the order that warms the cache


Run an English request followed by a French request, then repeat in the opposite order after resetting the test cache under controlled conditions. Also repeat each language request to exercise reuse.


If the first request determines every later response, the sequence exposes the defect. Testing only one language on a cold cache would miss it.


Include the absence of the language header and the application's documented fallback behavior. Where multiple language preferences are supported, test a representative preference list rather than only one simple value.


Inspect the response headers at the origin and after intermediary processing. A correct application header can still be removed or ignored by another layer. Record which cache configuration was actually tested.


Balance correctness with cache fragmentation


Varying on unnecessary or highly variable inputs can create many stored variants. Start from the inputs that genuinely change the representation, and review any attempt to normalize them for semantic correctness.


Do not remove a necessary distinction solely to improve a hit-rate number. A frequently reused wrong-language response is not a successful cache outcome.


For acceptance, keep a matrix of request conditions, expected language, observed language and whether the response was reused. Include the tested URL and configuration revision.


Keep the test resource deliberately easy to identify: a short language label and a fictional content-version marker are enough. Compare the whole expected response, including the marker, so the test does not pass merely because one translated word appears. This also helps distinguish a language-selection error from a separate stale-content problem when the same resource is revised.


The resulting evidence should demonstrate that a reader receives the intended representation regardless of which language warmed the cache first. That is a more useful measure than checking whether the cache reports a hit.


Continue with the related FutureOS guide for the related planning decision.


The published FutureOS introduction describes the project as being in prelaunch. Use this guide to prepare a concrete project discussion; it does not announce an available FutureOS feature.



Prepared with AI assistance. Primary sources checked on October 24, 2026. Examples and procedures are illustrative editorial guidance, not FutureOS product announcements or an independently reviewed assessment.

Comments


bottom of page