How can I make Varnish Cache compatible with redirects?

GeoIP redirect module is the Magento 2 extension and is not compatible with Varnish Cache. Magento 2 utilizes App Server and when you use Varnish Cache for your website the redirect functionality will not work properly.

However, you can use a solution that may bring partial compatibility.

You need to add the following code to the Varnish Cache configuration file (by default /etc/varnish/default.vcl) on your server:

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

Now, your store will be displayed without cache during the first visit. Please note that this solution only works when you set the First visit redirect only option to Yes. Otherwise, you will be unable to use redirects.

See more details on GeoIP Redirect for Magento 2 page

User Guide

How can we help you?

Didn’t you find the answer to your question? We are always happy to help you out.

© 2009-2022 Amasty. All Rights Reserved.