Guide: Fastly CDN Configuration

Created by Esther Nguyen, Modified on Sun, 19 Apr at 1:10 AM by Support Agent

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 further assistance, please don't hesitate to contact us. Don't forget that BSS Commerce is a full-service ecommerce agency with 14+ years of experience, supporting 75,000+ customers worldwide. As an Adobe Commerce Solution Bronze Partner and Select Magento Extensions Builder, we deliver trusted end-to-end solutions.


Our core strength is Magento, with 150+ extensions designed to enhance store performance and drive growth. With deep expertise from years of working on Magento websites, we deliver scalable, high-impact solutions backed by strong client trust.


Our most powerful extensions are BSS Commerce’s Magento 2 B2B Extension & BSS Commerce’s Magento 2 SEO Extension


Please visit our site for more useful Magento 2 Extensions: https://bsscommerce.com/magento-2-extensions.html

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