In Layout XML file, if we don't want to cache a block we use
cachable=false. By default, it's going to cache.
When to use
cachable=false & how it effects to website performance?
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.Sign up to join this community
Setting a block element
cacheable attribute to false can serve several purposes!
For example, the captcha block
\Magento\Captcha\Block\Captcha is not cached in Magento 2. It makes sense as it is a dynamic block.
Something you've got to keep in mind, is that if the
cacheable attribute is set to false on a block, it will make the entire page not cacheable which is not ideal in terms of performance.
Obviously, the more uncacheable blocks you have the worse the performance will be.