Skip to content

Commit

Permalink
Add "cacheable" param to distinguish between FPC vs non-FPC routes
Browse files Browse the repository at this point in the history
  • Loading branch information
sdesmet committed Apr 12, 2018
1 parent 8bc39a4 commit 9ce3ff8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
16 changes: 16 additions & 0 deletions app/code/community/Mpchadwick/PageCacheHitRate/Model/Observer.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class Mpchadwick_PageCacheHitRate_Model_Observer
*/
public function handleControllerFrontSendResponseBefore(Varien_Event_Observer $observer)
{

$config = Mage::getModel('mpchadwick_pagecachehitrate/config');
$trackers = $config->get('trackers');
if (!$trackers) {
Expand All @@ -25,6 +26,7 @@ public function handleControllerFrontSendResponseBefore(Varien_Event_Observer $o
$params = $paramProvider->baseParams(true) + array(
'type' => $type,
'route' => $this->trackerRoute(),
'cacheable' => $this->isRequestCacheable()
);

$factory = Mage::getModel('mpchadwick_pagecachehitrate/trackerFactory');
Expand All @@ -40,6 +42,20 @@ public function handleControllerFrontSendResponseBefore(Varien_Event_Observer $o
}
}

/**
* Determine this request is cacheable in FPC
*
* @return bool
*/
protected function isRequestCacheable()
{
$request = Mage::app()->getRequest();
$processor = Mage::getSingleton('enterprise_pagecache/processor');
$subprocessor = $processor->getMetadata('cache_subprocessor');

return $subprocessor !== null && $processor->canProcessRequest($request);
}

/**
* Get the type of response.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public function baseParams($originalRequest = false)
'userAgent' => $this->userAgent,
'isBot' => $this->isBot,
);

}

protected function getUrl($originalRequest)
Expand Down

0 comments on commit 9ce3ff8

Please sign in to comment.