Accept-Language Issue

Cosimo Streppone cosimo at streppone.it
Fri Jul 2 07:59:32 CEST 2010


In data 02 luglio 2010 alle ore 00:37:41, Laurence Rowe <l at lrowe.co.uk> ha  
scritto:

> Check that you do have the comma in Plone's caching control panel. I can
> imagine it being an easy typo to make.
>
> There are many unique variations of Accept-Language headers, so be  
> careful.
> I've used this before in vcl_recv to normalise the incoming request:
>
>   # We only care about the language in the I18N_LANGUAGE cookie
>   if (req.http.Cookie ~ "(^|.*; )I18N_LANGUAGE=") {
>     set req.http.Accept-Language = regsub(req.http.Cookie, "(^|.*;
> )I18N_LANGUAGE=([^;]*)(; .*|$)", "\2");
>     # XXX need to work out the proper way to match " here, e.g. "en"
>     set req.http.Accept-Language = regsub(req.http.Accept-Language,
> "^.(.*).$", "\1");
>   } else {
>     set req.http.Accept-Language = "en";
>   }

This is fine, as long as you always have a cookie.
We weren't in this situation, and we wanted to honour Accept-Language
properly, so I wrote this VCL:

http://github.com/cosimo/varnish-accept-language/

-- 
Cosimo



More information about the varnish-misc mailing list