I wanted to listen to the redirection of the home page in magento2. I used the controller_action_predispatch events and checked the full action cms_index_index.

But what I am facing is, The page gets identified the first time, but after that, it's not being identified by the observer.

I have to clean the cache again to make the observer identify it. and even so, it works only the first time.

This page is only for the home page. Every other page is working fine.

Also there is no problem when the cache is disabled. But there is a problem when cache is enabled.

  • the fpc works like you sayd, when the page is cached, your code not run, because the page is returned by the cache. what do you have to do with the redirection? explain better what you want. – LucScu Mar 28 at 10:42
  • I have a condition in my pre dispatcher,which is being checked before each page is loaded,i.e before the home page is loaded too. But this condition is not being checked currently for the home page. – Jerin Cherian Mar 29 at 9:33

Your Answer

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

Browse other questions tagged or ask your own question.