I want a store to intelligently choose a default currency based on the customer's IP using GeoIP when they first visit (with no preselected currency cookie). The store is behind Varnish using Nexcess's excellent Turpentine extension.
The extension handles currency fine as long as the standard Magento currency cookie is set on a given request.
My thoughts at this stage are:
- Add VCL into the Varnish config to do the GeoIP lookup (in C) and set the cookie on the inbound request, if it's not already set, of course.
- Add a per-user cached block that does the lookup and sets the cookie (though this would then not apply on the first page load)
Am I missing an obvious technique - maybe some client-side JS to a non-varnish-cached URL path that makes the determination?
Does anyone know the best way to do this?