Guide: Fastly CDN Configuration

Created by Esther Nguyen, Modified on Tue, 20 Aug at 11:50 AM by Esther Nguyen

QUESTION:


We are using Fastly CDN instead of Varnish for the full page cache. How can we configure Fastly CDN cache to be compatible with your GeoIP module?


ANSWER:


This is the configuration to make GEOIP work with Fastly CDN Cache.


You can choose between the two solutions below:


1, Create custom snippet in the backend: 

- Follow the guide: https://github.com/fastly/fastly-magento2/blob/master/Documentation/Guides/CUSTOM-VCL-SNIPPETS.md 

- Create custom snippet in the backend: https://drive.google.com/uc?id=1zUk96j-EYCbBVv4jhsRFsXtqqvD7OAXM 


2, Create custom snippet on Fastly:

- Edit Fastly CDN service: https://drive.google.com/uc?id=1lUBoCznvgk4BdC2zUXCYq-RXp0coqmNN


 if (req.http.cookie ~ "country_code=") {

        set req.hash += regsub(req.http.cookie, "^.*?country_code=([^;]+);*.*$", "\1"); 

    }

    if (req.http.cookie ~ "currency_status=") {

        set req.hash += regsub(req.http.cookie, "^.*?currency_status=([^;]+);*.*$", "\1");

    }

    if (req.http.cookie ~ "last_store_id_visited=") {

        set req.hash += regsub(req.http.cookie, "^.*?last_store_id_visited=([^;]+);*.*$", "\1");

    }

    if (req.http.cookie ~ "last_full_url_visited=") {

        set req.hash += regsub(req.http.cookie, "^.*?last_full_url_visited=([^;]+);*.*$", "\1");

    }

    if (req.http.cookie ~ "customer_has_redirected=") {

        set req.hash += regsub(req.http.cookie, "^.*?customer_has_redirected=([^;]+);*.*$", "\1");

    }

    if (req.http.cookie ~ "customer_has_open_popup=") {

        set req.hash += regsub(req.http.cookie, "^.*?customer_has_open_popup=([^;]+);*.*$", "\1");

    }


- Active new version


If you need any further assistance, please feel free to contact us. We'd be happy to support you!

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article