Something I learned only today that felt neat enough to share.
Problem:
How to cache a multilingual Plone site that uses cookie negotiation for language selection with Varnish.
Solution:
-
Keep dropping cookies at Varnish.
-
Enable also request based language negotiation (Accept-Language).
-
Configure Plone caching operations to set
Vary: Accept-Language
. -
Configure Varnish to map
I18N_LANGUAGE
-cookie value toAccept-Language
-header.if (req.http.cookie ~ {"I18N_LANGUAGE="[^"]+""}) { set req.http.Accept-Language = regsub(req.http.cookie, {".*I18N_LANGUAGE="([^"]+)".*"}, "\1"); } else { unset req.http.Accept-Language; }