# Caching Multilingual Place Pages Safely

An English-speaking traveler opens a place guide. A Vietnamese-speaking traveler follows the same shared link and sees English. Each visit works when tested on its own because the origin chooses the requested language. The problem appears when a shared cache serves the first response to both visitors. Multilingual travel pages provide a practical example. The routes and headers below are fictional. [Tripmap in English](https://tripmap.vn/en/about)

## Pick where language becomes part of the request

Use a locale in the URL when readers should be able to share a specific translation. With `/en/places/example` and `/vi/places/example`, the two paths identify distinct resources at the cache boundary. A language switch can take the reader directly to the other path. If a locale-specific route serves a fixed language, the origin can return `Content-Language` to describe the response language.

A site can also serve multiple languages from `/places/example`. If that origin chooses the language from `Accept-Language`, send `Vary: Accept-Language` on every version, including the default response. A cache uses `Vary` to determine which request headers participate in selecting a stored variant. `Content-Language` describes the response. `Vary` tells the cache how to distinguish requests. [RFC 9111, section 4.1](https://www.rfc-editor.org/rfc/rfc9111.html#section-4.1)

```http
HTTP/1.1 200 OK
Content-Language: vi
Vary: Accept-Language
Cache-Control: public, max-age=300
```

That example assumes a public page whose only language input is `Accept-Language`. A route that redirects to a locale-specific URL based on the same header must also account for the header if the redirect is cacheable. Verify the behavior of the shared cache you deploy, since its configuration determines whether and how it respects variants.

## Keep personal choices out of shared responses

If the HTML includes saved places, account details, or content personalized by a preference cookie, give that response its own caching policy. Use a shared cache for content that can be served identically to all readers of a variant. For per-user content, `Cache-Control: private` protects it from storage by shared caches. Choose a stricter policy if the response should also stay out of browser caches. [RFC 9111 cache directives](https://www.rfc-editor.org/rfc/rfc9111.html#section-5.2.2)

## Test the requests that warm the cache

1. Start with a cold cache. Request Vietnamese, then English at the same negotiated route. Assert the language of both response bodies.
2. Clear the cache and reverse the order. A response can look correct until the default variant happens to be the first one stored.
3. Repeat with the language header omitted. Assert the documented default and verify that it does not affect the next explicit language request.
4. Make a signed-in request and confirm that any personalized fragment stays outside the shared cache.

Run those checks through the same cache layer your readers reach. Checking only the origin can prove that translation selection works while missing the behavior visitors actually see.
