Jordy
Jordy

Reputation: 4809

Why don't websites use Vary: Accept-Language?

As far as I know you should aways set the Vary: Accept-language response header when working on a multi-language website. In my case the user gets redirected to a language specific page, e.g. http://www.example.com/nl/.

But I can't find any website that uses this Vary header. Why is that? Even the multi-language websites from Apple, Microsoft, Samsung, Facebook don't use this header.

Upvotes: 4

Views: 2860

Answers (2)

Valery Lourie
Valery Lourie

Reputation: 135

You can normalize Vary: Accept-Language in a similar way:

# Normalize Accept-Language
declare local var.lang STRING;
if (req.http.Accept-Language) {
  set var.lang = req.http.Accept-Language;
}
if (var.lang ~ "^da") {
  set req.http.Accept-Language = "da";
} elsif (var.lang ~ "^sv") {
  set req.http.Accept-Language = "sv";
} else {
  # unknown language
  remove req.http.Accept-Language;
}

Upvotes: -1

Shawn
Shawn

Reputation: 89

The simplest answer is that websites only support a small subset of the possible languages, which would mean web caches (ie. CDNs) would have to cache many many different versions of a page based on the Accept-Language header coming from the browser, when in reality there would only be few different versions. This is a problem because it causes cache fragmentation, which reduces cache hit ratio on the caching servers and consumes more resources (CPU/RAM/Disk).

Also Google recommends using a different url per language https://support.google.com/webmasters/answer/182192

Also Akamai used to not support caching based on the Vary header, except for Vary: Accept-Encoding, however I don't believe they still has this limitation. http://my.globaldots.com/knowledgebase.php?action=displayarticle&id=32

Upvotes: 2

Related Questions