We sacrifice by not doing any other technology, so that you get the best of Magento.

We sacrifice by not doing any other technology, so that you get the best of Magento.

    Please follow below steps to disable cache for block :

    –  layout cache disable:-
    1) You can use cacheable=”false” attribute in your layout to disable cache for a block but problem is that it will disable whole page cache.

    <block class="QaisarSattiHelloWorldBlockHelloWorld" name="helloworld" cacheable="false" />
    

    2) Another option for cache diable

    <block class="QaisarSattiHelloWorldBlockHelloWorld" name="helloworld"  ttl="30" />
    

    programmatically cache disable :
    Disable cache for block programmatically:-

    <?php
    /**
    * Simple Hello World Module
    *
    * @category QaisarSatti
    * @package QaisarSatti_HelloWorld
    * @author Muhammad Qaisar Satti
    * @Email qaisarssatti@gmail.com
    *
    */
    namespace QaisarSattiHelloWorldBlock;
    class HelloWorld extends MagentoFrameworkViewElementTemplate
    {
    public function getCacheLifetime()
        {
            return null;
        }
    
    }

     

    field_5bfb909c5ccae

      Get a Free Quote