Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore requests that are not eligible for FPC #37

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions app/code/community/Mpchadwick/PageCacheHitRate/Model/Observer.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,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 +41,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);
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code will only execute for cache misses or partials meaning that the cacheable param will not be added for hits. For hits the observer won't fire and the tracking is handled by Mpchadwick_PageCacheHitRate_Model_Processor.

Both consult Mpchadwick_PageCacheHitRate_Model_Tracker_ParamProvider::baseParams which is probably where this value should come from. That way you only need to write the logic once.


/**
* Get the type of response.
*
Expand Down