Developers need to send a Vary header on Accept-Language
Accept Language has lots of variations (language, script, region, subtags...)
This solution could lead to multiply each cache entry (example.com has many urls) by an order of thousand (all accept-language variations), leading to cache exclusions (LRU), thus tons of cache misses on edge servers. This would hurt performance a lot.
/.well-known/accept-language
es fr en en-US en-GB pt pt-BR zh zh-Hant
1) When user goes to example.com, the static page /.well-known/accept-language is queryied in parallel, and cached accordingly.
2) While the page is loading, the Browser checks /.well-known/accept-language fast response and determines if there is a better language for the user among those proposed by example.com
3) If so, Browser stops navigation and send Accept-Language: es
4) Browser receives es content and displays it.
5) On further navigations,
If the cache of the /.well-known/accept-language is valid, Browser queries this local cached file, select the best language and send Accept-Language: es
If the cache of the /.well-known/accept-language file is expired, Browser goes to step 1)
Problem
Given
This solution could lead to multiply each cache entry (example.com has many urls) by an order of thousand (all accept-language variations), leading to cache exclusions (LRU), thus tons of cache misses on edge servers. This would hurt performance a lot.
References on Vary and locales:
Solution
Expose accepted languages on a well-known url
1) When user goes to example.com, the static page
/.well-known/accept-language
is queryied in parallel, and cached accordingly. 2) While the page is loading, the Browser checks/.well-known/accept-language
fast response and determines if there is a better language for the user among those proposed by example.com 3) If so, Browser stops navigation and send Accept-Language: es 4) Browser receives es content and displays it. 5) On further navigations,/.well-known/accept-language
is valid, Browser queries this local cached file, select the best language and send Accept-Language: es/.well-known/accept-language
file is expired, Browser goes to step 1)References on well-known urls:
Other possibilities: