I have customBlock in product_view
. How do disable cache for this?
1 Answer
I assume you want to disable caching of the block by PageCache
module. There are two options available:
- Set
cacheable="false"
attribute in layout. But this will make the whole product page non-cacheable, probably is not what you want. Keep in mind existing issue withcacheable="false"
on product view page - Use UI components
- Do not set
_isScopePrivate
property totrue
in your block, this is deprecated functionality
-
-
-
1@Alex Paliarush I tried to set _isScopePrivate to true in my custom block to add a specific logo for the customer of tier price; but it seems not work. My custom block was not rendered by ajax.– Ricky.CCommented May 26, 2016 at 6:54
-
2cacheable="false" disables caching for the whole page! This is a recipe for performance degradation. See inviqa.com/blog/how-full-page-cache-works-magento-2 for details about caching. Commented Jan 30, 2017 at 12:37
-
1@Rick.C "Do not use the $_isScopePrivate property in your blocks. This property is obsolete and won't work properly." Find this in magento guide: devdocs.magento.com/guides/v2.1/config-guide/cache/…. I think this links is also helpful to guide how to disable cache in certain blocks. Commented Mar 15, 2017 at 0:57