Zend certified PHP/Magento developer

Block is getting cached in magento2

I am trying to disable cache for specific block,

Have used below code.

appcodeVendorModuleviewfrontendlayoutdefault.xml

<referenceContainer name="header.panel">            
        <block class="VendorModuleBlockIndex" name="custom_block" template="html/custom.phtml"/>
</referenceContainer>

appcodeVendorModuleBlockIndex.php

<?php

 namespace VendorModuleBlock;

 class Index extends MagentoFrameworkViewElementTemplate
 {
   public function __construct(
     MagentoFrameworkViewElementTemplateContext $context
      array $data = []
      ) {
        parent::__construct($context, $data);
        $this->_isScopePrivate = false;
     }

 public function getCacheLifetime()
 {
   return null;
 }
 }

Used getCacheLifetime and _isScopePrivate but not working. Please someone guide me on this.

Note: cacheable=”false” is not recommended

Thanks in advance!!