1

I created my module for GeoIP where I get location based on IP and set currency and stores according to It.

I have implemented the login in the first possible observer controller_action_predispatch to initiate this logic.

$currentIp = $this->_remoteAddress->getRemoteAddress();
$currency = $this->getCurrency($currentIp);
$this->_storeManagerInterface->getStore()->setCurrentCurrencyCode($currency);

The above implementation is just an sample of what I am doing and it works great.

However when implementing varnish in my server my logic fails. Now My question is I dint find any solution to make observer cacheable false as cacheable false works for blocks I guess. Even though I may get a solution to make it cacheable false will varnish implantation be logical as my observer will be called every time and I will get my page as miss.

What can I do to overcome this?

  • Are you using cookie? – padhiyar gaurang Sep 9 '17 at 5:31
  • @padhiyar gaurang Yes – Priyank Sep 9 '17 at 5:32
  • ohh!!! sometimes varnish is to unpredetable with cookie. It is due that or see my answer below. It may can help. – padhiyar gaurang Sep 9 '17 at 5:33
0

Please refere to this

http://blog.tenya.me/blog/2013/10/25/geoip-with-varnish/

Geo IP based store view selection with Varnish

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.