Magento events (including http_response_send_before) not launching observer with FPC activated

1k Views Asked by At

I am making a full-observer module in order to change the store view depending on the user's navigator language. My main function is launched by the <controller_action_predispatch> event.

All work just fine without FPC activated. But once FPC has been enabled and has generated its cache, Magento does not go through controllers anymore (not on regular pages like product view, category view or home page for example). I did my research and found that the event <http_response_send_before> is always dispatched, even with FPC enabled. So I changed my previous event listener for this one, and it works well without FPC too.

Now the problem is that when FPC is activated, the event is still dispatched correctly (made a log in the Mage function), but does not attach any observer to it. I don't know how Magento initializes the $_events in App.php once FPC is enabled but it seems to be the core of the problem. I have not found a single post about that on the internet, so any help would be greatly appreciated.

P.S. :

  • I work on a Magento EE 1.14.0.1.
  • I reproduced the same thing on a clean Magento of the same version, and the "problem" is present too.
  • The cache was of course entirely flushed after I changed the observed event.
  • This behavior occurred with the use of a custom event too.
1

There are 1 best solutions below

3
On

I stumbled across your post with exactly the same issue.

With Magento EE 1.14 FPC enabled, this event;

http_response_send_before

Fires a maximum of 2 times with a clean cache. After that, it never fires again and/or the method you specify gets cached. So after much testing of other events, I discovered that;

controller_action_predispatch

Consistently fires with FPC on. Swap your observed event to this, and all should be right with the world.

Best, Tom