GeoIP redirection and Varnish

时间:2017-11-02 15:41:31

标签: magento2 varnish geoip varnish-vcl

We have an ecommerce setup that uses GeoIP plugin to redirect users to the right store. The setup is as below:

Cloudflare -> Nginx -> Varnish -> Apache -> Magneto (GeoIP Plugin)

We have country specific home page redirections setup as per table below:

www.myecomstore.com from US goes to www.mystore.com/en-US
www.myecomstore.com from Canada goes to www.mystore.com/en-CA
www.myecomstore.com from Australia goes to www.mystore.com/en-AU

and so on...

We were told to add this code to Varnish to bypass first time visitors so the GeoIP module can redirect users properly to the right store instead of Varnish delivering cached home page content all the time.

if (req.http.cookie !~ "PHPSESSID=") {
    return (pass);
}

My understanding is the above varnish code will bypass first time visitors so they can be redirected properly to the right store. Subsequent visits by the same visitor will fetch from Varnish as required/possible.

Without the first-time bypass, visitors will be shown cached default home page irrespective of which country they came from.

Can someone please help clarify?

0 个答案:

没有答案