Varnish and language cookie

Laurence Rowe l at lrowe.co.uk
Fri Feb 26 16:51:30 CET 2010


I think this is your problem:

   11 TxHeader     b Cookie:
sessionid=fd0523a529b0a09861a235d1c2fdd7de; changed=true; open_tab=1;
rule_path=/general; django_language=fr;
   11 RxHeader     b Vary: Accept-Encoding
   11 RxHeader     b Vary: Accept-Language, Cookie

If your pages are the same for all users then you should remove Cookie
from the Vary.

I would also remove the custom vcl_hash and just set
req.http.Accept-Language to the value from the cookie, that way you
avoid caching multiple copies of any images etc.

Laurence

On 23 February 2010 15:47, Yann Malet <yann.malet at gmail.com> wrote:
> Hello,
> I am having hard time to to cache a multilingual web site. Vanish listen on
> port 80 and proxy the request to a multilingual django cms what I would like
> to do is to cache the pages per language and serve them from the
> cache. Unfortunately so far I have not been able to get this working and
> varnish keep on fetching th pages from the cms.
> I am going to add below all the information I think useful do not hesitate
> to let me know if you need more info ?
> Here it is my configuration :
> sub vcl_recv {
>     # clean out requests sent via curls -X mode and LWP
>     # http://varnish.projects.linpro.no/wiki/VCLExampleNormalizingReqUrl
>     if (req.url ~ "^http://") {
>         set req.url = regsub(req.url, "http://[^/]*", "");
>     }
>     # Set the backend based on the subdomain name
>     if (req.http.host == "static.gwadeloop.com") {
>         set req.backend = static;
>     }
>     if (req.http.host == "dev.gwadeloop.com") {
>         set req.backend = django;
>         # Add a trailing slash if missing
>         if ((req.url ~ "[^\]$") && (! (req.url ~ "^/media/"))) {
>             set req.url = req.url "/";
>         }
>     }
>     if (req.http.Cookie) {
>         # removes all cookies named __utm? (utma, utmb...)  -- Google
> Analytics
>         set req.http.Cookie = regsuball(req.http.Cookie, "(^|; )
> *__utm.=[^;]+;? *", "\1");
>         if (req.http.Cookie == "") {
>             remove req.http.Cookie;
>         }
>    }
>      if (req.http.Cookie ~ "django_language=") {
>          set req.http.X-Varnish-Language =
>              regsub(req.http.Cookie, "django_language=([a-z]{2})", "\1");
>      }
> }
> -------------------------
> sub vcl_hash {
>     set req.hash += req.url;
>     if (req.http.host) {
>         set req.hash += req.http.host;
>     } else {
>         set req.hash += server.ip;
>     }
>     set req.hash += req.http.X-Varnish-Language;
>     return (hash);
> }
>  -------------------------
> here it is the information outputed by varnishlog when I try to access the
> same page twice:
> http://dpaste.com/163624/
> I would be glad if someone could point me what I am doing wrong here.
> Regards,
> --yml
>
> _______________________________________________
> varnish-misc mailing list
> varnish-misc at projects.linpro.no
> http://projects.linpro.no/mailman/listinfo/varnish-misc
>
>



More information about the varnish-misc mailing list