Skip to main content

Caching Multilingual Place Pages Safely

Trace which language a shared cache will serve before you turn caching on

Updated 3 min readMarkdown
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

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

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

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.

3 views

About the author

  • Tripmap is a Vietnam-based travel technology platform on a mission to connect people with the real world through AI, geospatial intelligence, and digital innovation. We build intelligent travel discovery and booking solutions, combining AI agents, mapping technology, and tourism data to make exploring the world easier, smarter, and more accessible. Here, we share our engineering journey, technical insights, and experiences in building the future of travel technology. Built in Vietnam, for the world. 馃寪 https://tripmap.vn

No comments yet. Be the first to comment.