9

I have customBlock in product_view. How do disable cache for this?

1 Answer 1

10

I assume you want to disable caching of the block by PageCache module. There are two options available:

  1. 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 with cacheable="false" on product view page
  2. Use UI components
  3. Do not set _isScopePrivate property to true in your block, this is deprecated functionality
9
  • Thank alot . i will try it and answer you soon
    – xanka
    Commented Dec 11, 2015 at 10:04
  • @xanka Did it help? Commented Dec 18, 2015 at 9:07
  • 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.C
    Commented May 26, 2016 at 6:54
  • 2
    cacheable="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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.