DELTAWEB
All posts
Technical SEO

hreflang with CDNs and Caching: Common Vary Header Issues

hreflang can disappear or the wrong language version gets cached at the CDN layer. Learn how Vary headers, Accept-Language and URL-based separation help.

hreflang with CDNs and Caching: Common Vary Header Issues
9 minReading time
Arif KuruAuthor

An exporter's German page starts appearing in Google as the Turkish version, and buyers in Germany land on the wrong language. The engineering team insists the server is correct, yet a single response cached at the CDN layer may be serving the same content to every language. This scenario (a hypothetical example) shows that many hreflang problems begin not in the HTML tag itself but in the delivery layer behind it. If the basic logic is new to you, start with our pillar guide on what hreflang is; this article builds on that foundation.

Key Takeaways

  • Even when hreflang tags are correct, a CDN or cache can make Google and users see different versions of a page.
  • The Vary header tells caches which request header to key separate copies on; a missing or wrong value spreads the wrong language.
  • Content negotiation with Accept-Language is technically possible, but it reduces predictability for caches and crawlers.
  • A separate, stable URL for each language simplifies both the cache key and the hreflang signal for most export sites.
  • Exact behavior depends on your CDN provider and server setup, so verify every change against live responses.

Why is this problem so easy to miss?

hreflang tells search engines how pages covering the same content in different languages and regions relate to one another. Google's documentation for multilingual and multi-regional sites describes the markup using a language code and an optional region code, asks that each page in a cluster reference itself, and requires return links between pages. The annotations can be delivered in the HTML head, in HTTP headers, or through a sitemap. Read the current Google text for your own project; here we only summarize it.

The catch is that correct markup in the source does not guarantee that the right page reaches the user. A CDN or browser cache sitting between the origin and the visitor can return a response saved earlier for the same URL, and that response may belong to another language. The team cannot see this in the code, because the code is correct. Only the distributed system is serving the wrong version.

That is why hreflang problems are hard to close with a single fix. A team that corrects tags for a week and then watches the issue come back is usually dealing with a mismatch between cache decisions and page variants, not a broken tag.

Two separate layers: content and delivery

In practice, it helps to separate two kinds of problems. The first is the content signal: whether each page links to its counterparts, whether every version declares its own language, and whether return links are complete. The second is the delivery signal: whether the response differs depending on who asks, and whether that difference is stored under the right key in the cache. You find the first kind with Search Console and an hreflang audit tool. The second needs a look at response headers and cache behavior. This article focuses on the second layer.

Misdiagnosis happens most often here. When a team says "our hreflang is broken," the real cause may be that one cached version is being shown to everyone. The first step is therefore to request the same URL with different headers and compare the responses. If they match, the issue is most likely on the content side. If they differ, look at the delivery layer.

What does the Vary header do?

The HTTP Vary response header tells caches which request headers the server considered when choosing a response. Under RFC 9110, a cache must compare the values of the listed request headers before it reuses a stored response. A response with Vary: Accept-Language therefore signals that Turkish and English requests need separate entries.

The mechanism cuts both ways. If Vary is missing while the server picks a language from the header, the cache can hand one language to everyone. If Vary lists too much, cache keys fragment and the hit rate drops. Vary: * means the response cannot be stored for reuse at all, which in practice turns caching off for that resource.

Comparing common Vary values

Response headerGeneral cache behaviorhreflang risk
No VaryOne entry per URLIf the server picks a language from headers, the wrong version can spread
Vary: Accept-LanguageSeparate entry per languageSound when it works; coverage and crawler behavior can stay hard to predict
Vary: CookieSeparate entry per cookie valuePersonal cookies can fragment the cache badly
Vary: *Effectively not cachedPerformance loss; the language signal still reaches the origin on every request

This table summarizes general behavior. Vary support, the headers a provider includes in its cache key, and how long entries live all vary by provider. Test in your own environment before you decide anything.

Risks of Accept-Language content negotiation

Content negotiation, meaning the server reads the browser's Accept-Language header and picks a language automatically, is technically feasible. Combined with hreflang, though, it introduces several risks:

  1. Inconsistent crawling: A search engine may not request each URL with the same Accept-Language value, so the version it sees can differ from what you assume. Having each URL return its own fixed content is sturdier than relying on automatic language selection.
  2. Cache fragmentation: When each language variant becomes its own cache entry, CDN hit rates fall and revalidation requests grow. That cost shows up as load and latency.
  3. Unverifiable results: A user who shares a link may open it and see another language. The fixed correspondence that hreflang expects breaks, and it becomes hard for a team to reproduce a reported bug.
  4. Restricting language choice: Automatic redirects based on language can take away a visitor's ability to pick their own language. Google's multilingual site guidance suggests offering users a choice rather than redirecting them automatically; check the current text yourself.

In short, Accept-Language based negotiation is an architectural decision, not just a technical option. If you choose it, you have to plan Vary, the cache key and crawler behavior together. Systems built without that planning often fail at the first traffic spike.

How does the wrong language get cached?

Consider a general scenario (a hypothetical example). The first request comes from a browser that prefers German and lands on the root address. The server returns the German version. The response has no Vary header, so it is cached. The next request, this time for a Turkish visitor, reaches the same address, finds the cached entry, and shows German content. This can happen without any code change; request order and cache lifetime are enough.

A similar result follows when the server does send a Vary header but the CDN does not include that header in its cache key. Here we do not give a specific product setting. Check your provider's documentation for which headers form the cache key and whether Vary is honored. Note that the information is sometimes split across several layers (browser, CDN, origin cache), so confirm each one.

Another common case is a long cache lifetime that delays content updates. That is a freshness problem rather than a language problem, but when a user sees the wrong language, the two can look identical. Read the response age and cache headers together when you diagnose it.

Why is URL-based separation more predictable?

Google's general direction is to give each language and region version its own stable URL. For example, a root address for the default language and separate paths such as /de/ and /en/, each returning the same content every time. In that setup the cache key is the URL alone, so every language gets its own entry without any Vary header. The hreflang annotations also attach to fixed URL identities.

Separate URL per language: pros and cons

  • Pro: Cache behavior becomes predictable, and language can be verified by opening a link.
  • Pro: hreflang relationships attach to stable URLs, which makes audits and debugging easier.
  • Con: Content, maintenance and translation work grows with every language.
  • Con: Changing the language structure later means URL migration and redirect work.

When you decide whether this structure fits, the checklist in our international SEO guide on hreflang errors makes the work easier. We cover return tag problems separately in our return tag errors article; the two issues usually need to be solved together.

Checklist: verifying hreflang at the CDN and cache layer

Apply these steps to real responses. Reading the source alone is not enough.

  1. Request the same URL with different Accept-Language values and record the language returned.
  2. Note the Vary and Cache-Control values in the response headers.
  3. Confirm in your provider's documentation which headers form the cache key.
  4. Check that every hreflang target URL returns 200 and contains its own language annotation.
  5. Use an audit tool to confirm that return links are reciprocal.
  6. Keep a procedure for purging the cache entry when a language version changes.
  7. For x-default, see our x-default guide and separate the selector page from the default version.

Running this list after every cache or deployment change works better than running it after every article. That way you can tell which change triggered a problem.

Uncertainties: what do we not know for sure?

Presenting everything here as settled would be misleading. The known and uncertain points are these:

  • The Accept-Language values Googlebot sends are not fixed, so do not design around a specific value.
  • Cache behavior depends on the CDN provider, plan and configuration, and general rules may not hold exactly in every environment.
  • Which version a search result shows depends on several signals combined, not a single one. hreflang is a hint, not a forced redirect.

Symptom, cause and first check

SymptomLikely causeFirst check
Wrong language in search resultshreflang missing or no self-referenceRead the alternate tags in the page source
Users see the wrong languageWrong variant in cacheCompare responses for different Accept-Language values
Content does not update after a language changeStale cache entryCheck purge behavior and response age

Conclusion and next step

Problems with hreflang in CDN and cache layers usually come from delivery decisions more than from the tag itself. Understanding Vary correctly, seeing the risks of Accept-Language negotiation, and taking advantage of URL-based separation for most export sites reduces the problem at its source. If you want to see how script codes such as zh-Hans and zh-Hant are used in the language attribute, our article on script codes in hreflang covers that next.

As a next step, pick the three highest-traffic pages this week. Request each one with two different language headers, compare the responses, and record the Vary values in a table. Reproduce those records in a test environment before any broad change in production. This article is a technical guide; it does not promise any result, timeline or performance gain.

FAQ

Frequently Asked Questions

  • Does a CDN delete hreflang tags?

    No, a CDN does not delete hreflang tags directly. However, if an outdated or wrong-language response is stored in the cache, search engines and users can see different versions. Request the same URL with different headers and compare the responses to find the problem. Even when the source code looks correct, check the delivery layer as well.

  • Is Vary: Accept-Language required for hreflang?

    No, it is not required. Vary is needed only when the server returns different responses based on Accept-Language, so that caches know to store them separately. If each language has its own stable URL, you usually do not need a Vary header at all.

  • Does the Vary header affect SEO rankings?

    Vary is not a ranking factor in itself; its effect is indirect, through which page the search engine and the user actually receive. When it is used incorrectly, the wrong language version can be served, which weakens the hreflang signal. Verify its effect by comparing responses rather than guessing.

  • What should I do if a wrong-language version was cached?

    First purge the cache for the affected URL, checking your provider's documentation for the supported method. Then request the URL again with different language headers to confirm the correct response comes back. Finally, document the cause, such as a missing Vary header or a cache key error, so it does not recur.

  • Does Google redirect users based on the Accept-Language header?

    We do not promise a specific behavior here, because crawling conditions can change. Google's multilingual site guidance suggests offering users a choice rather than redirecting them automatically based on language. Read the current documentation for your site and avoid designs that depend on how crawlers behave.

  • Does putting hreflang in the sitemap solve the CDN problem?

    A sitemap is an alternative to the HTML head annotations and does not remove the cache problem by itself. It can reduce risk in some cases because part of the signal no longer depends on the page response. Treat the sitemap as a complementary source rather than the main signal.

  • Is Vary: * a safe fix?

    Usually not. Vary: * means the response cannot be stored for reuse, which increases origin load and latency. A more predictable way to keep language accurate is to use a stable URL for each language and keep each URL's response consistent.

  • Why is URL-based separation recommended?

    A separate URL per language keeps the cache key tied to the address alone, which reduces complexity and anchors hreflang relationships to stable identities. It also means users and crawlers see the same content from the same link every time. The cost is more content, maintenance and translation work for each language.

Related Articles

No comments yet

Leave a Comment