In short
A cache stores a response so it can serve it again without recomputing it. On a multilingual site, it must always return, for a given URL, the response in that URL's own language, whoever filled the cache. The task is to review each layer (page cache, object cache, reverse proxy, CDN, incremental regeneration, service worker) and check its cache key and its purge. Once the task is done, the language served depends only on the URL, and editing a translation updates every page concerned.
Why it matters
A cache key is the identifier under which a response is stored. By default, it is the URL, sometimes without the host name. As long as each language has its own URL, all is well. Incidents come from four situations:
- Same URL, several languages: the root
/, or a page that picks its language from a cookie or theAccept-Languageheader. The first visitor fills the cache, and everyone after them gets that visitor's language, crawlers included. - Key without the host name: with subdomains (
de.example.com) or country domains, two languages share the same cache entry for/tarifs/. - Fragments without the language: the menu, the footer or a product block are cached under a shared key (
menu-principal). A French page shows the German menu. - Partial purge: a translation changes its slug, only its page is purged, and the other languages keep announcing the old URL in their hreflang annotations and their switcher.
These defects are intermittent: they depend on who filled the cache first. They therefore often slip past manual tests, but not past crawlers, which crawl with no cookie and no Accept-Language. When Googlebot receives a German page under a French URL, it may index it as is.
What it improves
- Reliable indexing of each language The response served to crawlers is the one for the URL, not the previous visitor's.
- Visitor experience No more pages or menus in another language.
- Up-to-date hreflang and switcher The purge covers every linked translation.
- Cache hit rate A simple key (URL and host) avoids fragmenting the cache by browser language.
- Citations in AI answers AI crawlers receive the right language under each URL. Indirect effect.
How to check
1. Does a URL's language hold up against the visitor's headers? Fill the cache as a German visitor, then read the page without a language header:
url=https://example.com/fr/tarifs/
curl -s -o /dev/null -H "Accept-Language: de-DE,de;q=0.9" -H "Cookie: lang=de" "$url"
curl -s -D - "$url" | grep -i -E "^(age|cf-cache-status|x-cache|x-vercel-cache|x-litespeed-cache|vary):|<html"
Expected result: a cache indicator (HIT, or an age greater than 0) and lang="fr". Replace lang=de with the actual name of the language cookie, visible in the Application tab of the developer tools. Run the test the other way round too, filling the cache in French on a German URL.
2. Are hosts kept apart? With subdomains or country domains, request the same path on two hosts and compare the lang attribute:
for host in example.com de.example.com en.example.com; do
printf '%-20s ' "$host"
curl -s "https://$host/tarifs/" | grep -o -i '<html[^>]*lang="[^"]*"'
done
3. Do fragments follow the language? On one page per language, check the language of the menu, the footer, the cookie banner and the "related articles" blocks. A word from another language in these areas points to a badly keyed object cache.
4. Does the purge cover the translations? Change the slug of a translation, then check in the other languages that the switcher and the hreflang annotations point to the new URL:
curl -s https://example.com/fr/tarifs/ | grep -o '<link rel="alternate" hreflang="[^"]*" href="[^"]*"'
5. Vary: a Vary: Accept-Language or Vary: Cookie header on inner pages means the response depends on the visitor's language, which should only apply to the root.
How to implement
Before you start
List the caches, from the browser to the database:
| Layer | Example | Expected key | Purge when a translation is updated |
|---|---|---|---|
| CDN | Cloudflare, CloudFront, Fastly | Scheme, host, path | URLs of all linked translations |
| Reverse proxy | Varnish, Nginx fastcgi_cache |
Scheme, host, path | Same |
| CMS page cache | WP Rocket, LiteSpeed Cache | URL, one file per language | Same, plus the language's home page and listings |
| Object cache and fragments | Redis, Memcached, transients | Fragment name + language | Fragments of the language concerned |
| Incremental regeneration | Next.js ISR | Path with language prefix | Paths of all translations |
| Service worker | Workbox | URL | New version of the service worker |
Common rules:
- The language comes from the URL: a cache keyed on the full URL is then correct with no tuning. If an inner page changes language based on a cookie or a header, fix that first: see avoid handling language only through cookies/JS (opens in a new tab).
- The root is a special case: if
/routes visitors based on their language, keep it out of the shared cache, or vary the cache by normalized language (see Cloudflare). - Purge by translation group: on every edit, purge the edited URL and those of all its translations, since they show its URL in their hreflang annotations.
Nginx
Versions Nginx 1.18 and later.
Check that the cache key includes the host, which is essential with subdomains or several domains:
fastcgi_cache_key "$scheme$request_method$host$request_uri";
# or, for proxy_cache:
proxy_cache_key "$scheme$request_method$host$request_uri";
The default value of proxy_cache_key is $scheme$proxy_host$request_uri: $proxy_host is the upstream server's host, the same for every language if they go through the same backend. Replace it with the $host version.
Exclude the root from the cache if it depends on the visitor's language, in the server block:
location = / {
fastcgi_cache_bypass 1;
fastcgi_no_cache 1;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root/index.php;
fastcgi_pass unix:/run/php/php8.4-fpm.sock;
}
Adapt the socket. Reload with sudo nginx -t && sudo systemctl reload nginx and empty the cache folder.
Varnish
Versions Varnish Cache 6.0 LTS to 8.0 and Vinyl Cache 9, the open source project's new name since 2026 (the varnish… commands become vinyl…, for example vinyld).
Varnish's built-in vcl_hash function combines the URL and the Host header: hosts stay separate as long as you do not override it. If your VCL defines its own vcl_hash, keep the host:
sub vcl_hash {
hash_data(req.url);
if (req.http.host) {
hash_data(req.http.host);
} else {
hash_data(server.ip);
}
return (lookup);
}
Also check that vcl_recv does not strip the language cookie on a page whose language depends on it, and that the root goes straight to the server if it routes visitors:
sub vcl_recv {
if (req.url == "/") {
return (pass);
}
}
To purge a translation group, use a ban on an expression that covers the URLs concerned, for example varnishadm 'ban req.url ~ "^/(fr/tarifs|de/preise|en/pricing)/"'.
Cloudflare
Versions Cloudflare dashboard, all plans (custom cache keys: Enterprise), November 2026.
Cloudflare's default cache key contains the full URL, host included: languages in subfolders, subdomains or separate domains are kept apart with no tuning.
Points to check:
Varyignored by default: Cloudflare disregardsVary(exceptAccept-Encoding) unless a Cache Rule turns on the Vary setting. A page that varies onAccept-Languageand is cached by a rule will therefore be served in a single language. If you need to cache a root that routes by language, create a Cache Rule limited tohttp.request.uri.path eq "/", turn on Vary with the "normalize" action onAccept-Languageand the list of your languages, and have the origin sendVary: Accept-Language. Otherwise, exclude/from the cache.- Language cookies: a Cache Rule that caches HTML ignores cookies in the key. A page whose language depends on a cookie will get mixed up. Custom cache keys (cookie, headers, country, language) are reserved for the Enterprise plan.
- Purge:
Caching > Configuration > Purge Cache > Custom Purge, URL option, listing every translation. Through the API, send the list of URLs in a singlepurge_cachecall.
AWS
Versions Amazon CloudFront console and AWS CLI v2, November 2026.
On CloudFront, the cache key is defined by each behavior's cache policy. Open the CloudFront console, Policies > Cache section, and check:
- that the
Hostheader is forwarded or included if several language domains point to the same distribution; - that
Accept-Languageand language cookies are not part of the key for inner pages, which would fragment the cache for no reason; - that the root's behavior, if it routes by language, uses
CachingDisabledor a redirect function that runs before the cache.
Purge a translation group with a single invalidation:
aws cloudfront create-invalidation --distribution-id DISTRIBUTION_ID --paths "/fr/tarifs/" "/de/preise/" "/en/pricing/"
LiteSpeed
Versions LiteSpeed Web Server 6 and OpenLiteSpeed 1.7 and 1.8, LiteSpeed Cache for WordPress plugin 7.
LSCache keeps URLs apart like other page caches. With the LiteSpeed Cache for WordPress plugin, what gets purged on publication depends on the rules under LiteSpeed Cache > Cache > Purge (automatic purge on publish or update) and on the translation plugin: do not assume linked translations are purged. Check that the edited translation and its equivalents are purged, with the x-litespeed-cache: miss header on the next request, and purge them by hand if they are not.
WordPress
Versions WordPress 6.4 and later, WP Rocket 3, WPML 4 or Polylang 3.
- Page cache: WP Rocket supports WPML and Polylang. With Polylang, the WP Rocket documentation states that each visitor's first visit is not cached while the language is being detected, and that caching kicks in once the
pll_languagecookie is set. With WPML, per-language purging and preloading assume the directory URL format. For other cache plugins, check their documentation for compatibility with your translation plugin. - Object cache and transients: a theme or plugin that stores a menu or a list under a fixed key shares it across languages. Add the language to the key:
$lang = function_exists('pll_current_language') ? pll_current_language() : apply_filters('wpml_current_language', null);
$key = "related_posts_{$post_id}_{$lang}";
$related = get_transient($key);
if ($related === false) {
$related = theme_related_posts($post_id);
set_transient($key, $related, HOUR_IN_SECONDS);
}
- Purge: after editing a translation, purge its equivalents too. With WPML or Polylang, WP Rocket lets you clear and preload the cache of one language or of all of them (
Clear and preload cache).
Laravel
Versions Laravel 11 to 13; spatie/laravel-responsecache 8 (Laravel 12 and 13) or 7 (Laravel 11).
Add the current language to every fragment cache key:
$locale = app()->getLocale();
$menu = Cache::remember("menu.main.{$locale}", now()->addHour(), fn (): Collection => Menu::forLocale($locale)->items());
With spatie/laravel-responsecache, check that the language is part of the URL (route prefix): the package stores responses by URL. If a page depends on the session for its language, it must not be cached. To purge a translation group, forget the URLs of each language (ResponseCache::forget(['/fr/tarifs', '/de/preise'])) or tag responses by content and clear the tag (ResponseCache::clear(['page-42'])).
Next.js
Versions Next.js 15 and 16 (App Router).
- Incremental regeneration: each language is a separate path (
/fr/tarifs,/de/preise). When a translation is published, revalidate all linked translations:
// app/api/revalidate/route.ts
import { revalidatePath } from 'next/cache';
export async function POST(request: Request) {
const { paths } = await request.json();
paths.forEach((path: string) => revalidatePath(path));
return Response.json({ revalidated: paths });
}
Protect this endpoint with a secret shared with the CMS. With tags, tag data requests by content rather than by language, so that a single invalidation covers every translation. Since Next.js 16, revalidateTag takes a second argument (revalidateTag('page-42', 'max'), or { expire: 0 } for immediate expiry); the single-argument form, used in Next.js 15, is deprecated.
- Data cache: with the
use cachedirective (stable since Next.js 16 with thecacheComponents: trueoption, experimental in Next.js 15), the function's arguments are part of the key; pass the language as an argument rather than reading it from a global variable or a cookie. - Proxy: if
proxy.ts(middleware.tsbefore Next.js 16) routes the root based onAccept-Language, addVary: Accept-LanguageandCache-Control: private, no-storeto that response.
Shopify
Versions Shopify, all plans, November 2026.
Shopify's cache keeps each language's URLs apart and is purged on publication: nothing to configure. Only check apps that cache their own blocks (reviews, recommendations): their text must follow the page's language.
Common mistakes
- Caching a root that routes by language: the first visitor decides the language for everyone else.
- Cache key without the host with language subdomains:
de.example.com/tarifs/receives theexample.com/tarifs/page. - Fragments cached without the language: menus, footers and widgets in the wrong language on pages that are otherwise correct.
- Adding
Vary: Accept-Languageto every page: the cache splits into as many entries as there are browser language combinations, and several CDNs ignore it or refuse to cache. - Purging only the edited page: the other languages show the old slug in their hreflang annotations.
- Testing only once: the defect only shows up once the cache has been filled by a visitor in another language.
Frequently asked questions
Should you send the Vary: Accept-Language header?
Only on responses that really change with the browser's language, which in practice means a root that routes visitors. When each language has its own URL, the cache relies on the URL and Vary is useless. On every page, it fragments the cache, and some CDNs ignore it by default or refuse to cache the response: Cloudflare only takes it into account if a Cache Rule turns it on.
Why does a visitor sometimes see the page in the wrong language?
Most often, a cache has stored two different responses under the same key: a page whose language depends on a cookie or on the Accept-Language header, language subdomains sharing a key without the host name, or a fragment such as the menu cached without the language. The defect is intermittent, because it depends on the language of the visitor who filled the cache first.
Should every language be purged when a translation is edited?
Purge at least the edited page and all its translations. Each translation shows the URLs of the others in its hreflang annotations and in its language switcher: if the slug changes, pages that were not purged point to an old address. Listings in the same language (home page, category, feed) also need purging if the title or the excerpt changed.
Should the language cookie be part of the cache key?
No, if the URL carries the language: the cookie only stores a choice and does not change the page's content. Adding it to the key multiplies entries for no benefit. If a page changes language based on the cookie, it is the architecture that needs fixing, because crawlers, which have no cookie, will only ever see one language of that page.
Resources
- MDN: Vary headerdeveloper.mozilla.org
- Google Search Central: Localized versions of your pagesdevelopers.google.com
- Nginx: proxy_cache_key and fastcgi_cache_keynginx.org
- Varnish: Built-in VCLvarnish-cache.org
- Cloudflare: Cache keys and Vary supportdevelopers.cloudflare.com
- Amazon CloudFront: Cache policiesdocs.aws.amazon.com
- WP Rocket: Multilingual pluginsdocs.wp-rocket.me
- Next.js: revalidatePathnextjs.org
Updated on
Topic checklist (PDF)