Skip to content
Open
Show file tree
Hide file tree
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
10 changes: 7 additions & 3 deletions src/code/Cache/Block/Messages.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,16 @@ class Made_Cache_Block_Messages extends Mage_Core_Block_Messages
{
protected function _toHtml()
{
if (Mage::helper('cache/varnish')->shouldUse()
&& !$this->getBypassVarnish()) {
$helper = Mage::helper('cache/varnish');
$request = Mage::app()->getRequest();
if ($helper->shouldUse()
&& $helper->getRequestTtl($request)
&& !$this->getBypassVarnish()
) {
return Mage::helper('cache/varnish')
->getEsiTag('madecache/varnish/messages');
}

return parent::_toHtml();
}
}
}
13 changes: 13 additions & 0 deletions src/code/Cache/Model/VarnishObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ public function addLayoutHandle(Varien_Event_Observer $observer)
if (!Mage::helper('cache/varnish')->shouldUse()) {
return;
}
$request = Mage::app()->getRequest();

if (!Mage::helper('cache/varnish')->getRequestTtl($request)) {
return;
}

$observer->getEvent()
->getLayout()
Expand All @@ -77,6 +82,14 @@ public function addEsiTag(Varien_Event_Observer $observer)
if (!Mage::helper('cache/varnish')->shouldUse()) {
return;
}
$headers = Mage::app()->getResponse()->getHeaders();
foreach ($headers as $header) {
if (strtolower($header['name']) == 'content-type') {
if ($header['value'] == 'application/json') {
return;
}
}
}

$block = $observer->getEvent()->getBlock();

Expand Down