Enterprise Edition Controller events do not fire if full page cache is enabled

So, on one of our recent launches, we had a lot of events that we observed, such as controller_action_predispatch. As soon as the site went live, we began to notice that our observers were never attracted to them. After a little investigation, one of our developers found this block of code in Mage_Core_Model_App around line 292

if ($this->_cache->processRequest()) { $this->getResponse()->sendResponse(); } else { $this->_initModules(); $this->loadAreaPart(Mage_Core_Model_App_Area::AREA_GLOBAL, Mage_Core_Model_App_Area::PART_EVENTS); if ($this->_config->isLocalConfigLoaded()) { $this->_initCurrentStore($scopeCode, $scopeType); $this->_initRequest(); Mage_Core_Model_Resource_Setup::applyAllDataUpdates(); } $this->getFrontController()->dispatch(); } 

As you can see, is $ this → _ cache-> processRequest () really true that it is when the full page cache is turned on that you never get sent. The developer really found a http_response_send_before which causes a call anyway, but it seems to me that this is a mistake, or you should never use these dispatch manager events for anything if full page caching is enabled. Any thoughts?

+8
magento
source share
4 answers

Given the nature of full page caching, I would call it "works as intended." Although it may be a little strange that they didn’t need to trigger any events, they needed to select a line, and this makes sense to me, especially since the controller is never sent.

You should use these dispatch manager events for everything that affects the page (since it still needs to be generated), but if you use it for tracking, etc., this is not suitable.

+7
source share

See here if you want to know how Caching works with Magento Enterprise.

http://magentophp.blogspot.com/2011/02/magento-enterprise-full-page-caching.html

+4
source share

The only reliable event to listen with and without the full page cache is http_response_send_before .

+1
source share

controller_front_send_response_before

This event will fire regardless of whether FPC is enabled.

0
source share

Source: https://habr.com/ru/post/651241/


All Articles