I have a redirect in my store that shows a different store view based on the client's location. It reads the header via Fastly and redirects the customer to a different store view using every time the same URL.
When there are many customers accessing the store the cache is mixed, even with the redirect working the cache is distributed to all customers in any location, making customers from the UK see the US store view.
How could I customize the cache block via VCL file to not just redirect by distributing cache based on the location?
1 Answer 1
I faced the same issue on varnish in currency switcher. I used the vary header concept to fix this issue. We need to add country code as a vary header, in this way each country generates a separate cached version of the same URL in fastly. We can add a vary header in fastly as well. Refer below links for more details.
https://www.fastly.com/blog/best-practices-using-vary-header
https://developer.fastly.com/reference/http/http-headers/Vary/