Serves Language Cookie


#1

Fastly is using Varnish 2.1.5 and allows custom VCL. I created my vcl and it worked on my local server. By the way, when i converted it to make it work with fastly.

My site has multiple Languages with url: http:// domain(dot)com/en (English for example) and it creates the cookies name WebLang=en.

Here is my custom vcl file:

I am a bit confused with the vcl_recv. Shoult I add:

if (req.url ~ "en") {
    set req.http.MyLang = "MyLang=en";
} elseif (req.url ~ "ja") {
    set req.http.MyLang = "MyLang=ja";
} elseif (req.url ~ "es") {
    set req.http.MyLang = "MyLang=es";
} elseif (req.url ~ "it") {
    set req.http.MyLang = "MyLang=it";
} elseif (req.url ~ "de") {
    set req.http.MyLang = "MyLang=de";
} elseif (req.url ~ "pt") {
    set req.http.MyLang = "MyLang=pt";
} elseif (req.url ~ "fr") {
    set req.http.MyLang = "MyLang=fr";
}

Thanks


#2

I think that might be to general.
You will match on any request that includes an en for the first match regardless if it is the first part of the URL.

Maybe a match on “^/en”

Have you tested this on any URLs yet?


#3

Yes. i tested them. en is default one.