nexcess / magento-turpentine

A Varnish extension for Magento.
GNU General Public License v2.0
520 stars 254 forks source link

flushing private cache flushe entire website cache #1504

Open rameshramachandran84-zz opened 5 years ago

rameshramachandran84-zz commented 5 years ago

Hi ,

We noticed an issue related to flushing private block cache flushing entire website cache .

We have configured Flush Event action for controller_action_predispatch which is fired on EVERY request. Every time page is dispatched. See Below.

private

We have similar configuration for Footer Block. Note that Header and Footer blocks are part of EVERY page in Magento.

look at the code that actually initiates FLUSH Event. This code is from turpentine extension. public function banClientEsiCache( $eventObject ) { $eventName = $eventObject->getEvent()->getName(); if( Mage::helper( 'turpentine/esi' )->getEsiEnabled() && !in_array( $eventName, $this->_esiClearFlag ) ) { $sessionId = Mage::app()->getRequest()->getCookie( 'frontend' ); if( $sessionId ) { $result = $this->_getVarnishAdmin()->flushExpression( 'obj.http.X-Varnish-Session', '==', $sessionId, '&&', 'obj.http.X-Turpentine-Flush-Events', '~', $eventName ); Mage::dispatchEvent( 'turpentine_ban_client_esi_cache', $result ); if( $this->_checkResult( $result ) ) { Mage::helper( 'turpentine/debug' ) ->logDebug( 'Cleared ESI cache for client (%s) on event: %s', $sessionId, $eventName ); } else { Mage::helper( 'turpentine/debug' ) ->logWarn( 'Failed to clear Varnish ESI cache for client: %s', $sessionId ); } } $this->_esiClearFlag[] = $eventName; } }

we can see that turpentine BANS the block by $sessionId which is actually the Frontend Cookie. (Magento assigned cookie for user session) As a result, even if we want to flush Header and Footer, its actually flushing all pages tagged with "Frontend" cookie.

Please let us know your thoughts .

rameshramachandran84-zz commented 5 years ago

@miguelbalparda : please share your thoughts

rameshramachandran84-zz commented 5 years ago

@eth8505 : please check

rameshramachandran84-zz commented 5 years ago

Hi, We identified the root cause. the flush events associated with each block is not only flushing the block cache, it is flushing the entire website cache and this is causing issues . As per the Doc its mentioned that cache will only flush for the particular blocks not for the entire pages.

miguelbalparda commented 5 years ago

Would you mind doing a PR with your findings?

rameshramachandran84-zz commented 5 years ago

@miguelbalparda : Can you please get me some idea about the BAN functionality . Is the BAN will flush entire page cache or its only flush particular block cache?

rameshramachandran84-zz commented 5 years ago

@miguelbalparda @aricwatson:

the above code added for the header block . So how can we confirm the ban request will only clear the header block cache not the full page cache . Is there any to make sure this . Please let me know .