I just go through other similar questions but they didn't help much. As per suggested in some answers to put the cacheable="false"
in block will disable it.
But it will disable whole page caching as per this documentation and here if that block is exist in any page.
I have an issue that after customer login in system, in header still showing the login link and showing wrong user name due to caching.
Is there any way I can exclude the header block from caching?
Best Answer
The customer specific data(private data) is not a part of the public content, so there is no need to disable caching using
cacheable
attribute.Regarding the issue, the proper section of documentation is http://devdocs.magento.com/guides/v2.2/extension-dev-guide/cache/page-caching/private-content.html
The private data is stored in browser local storage. This data is cleaned up using the rules described in section.xml files. For your case, the xml will be like following:
It means that browser will flush the data in local storage on every POST request to the urls described above (except /customer/ajax/login - for this case Magento do only partial cleanup). So, to fix your issue you need to check:
section.xml
file. If no, just add it in custom modulesection sources