1

I've got in a custom module created on module/view/frontend/layout/default.xml with:

<block class="\Magento\Framework\View\Element\Template" template="sample:module::sampletemplate.phtml" name="sampleblock" cacheable="false" _isScopePrivate="true"/>

I think that if i put the cacheable="false" to dont let the block to be cached, but it's not working.

How could i could remove cache of this block?

Raphael at Digital Pianism
70.8k37 gold badges192 silver badges357 bronze badges
asked Apr 1, 2016 at 10:35

1 Answer 1

5

In block class set _isScopePrivate property to true on __construct() function.

So add this to your class

public function __construct(){
$this->_isScopePrivate = true;
}
answered Apr 1, 2016 at 12:31
5
  • 1
    Check this if you want to use _isScopePrivate devdocs.magento.com/guides/v2.1/config-guide/cache/…, _isScopePrivate is obsolete Commented Mar 15, 2017 at 1:04
  • ..and that link is obsolete too. Commented Feb 7, 2020 at 16:03
  • 1
    _isScopePrivate is already obsolete as per the Magento 2 documentation devdocs.magento.com/guides/v2.4/extension-dev-guide/cache/… Commented Nov 12, 2020 at 4:20
  • @phagento Any idea how to fix that? How can i use private content? Commented Oct 31, 2022 at 9:12
  • @SunnyRahevar Use AJAX Commented May 26, 2024 at 9:15

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.