I need to remove the cache from my Block class, even if it removes the cache from the entire page.
How could I do it?
You can implement the HTTP
class and call the method setNoCacheHeaders
, as you can see below.
use Magento\Framework\App\Response\Http;
public function myCustomMethod(){
$this->response->setNoCacheHeaders();
...
}
It will implement this module below, which will set no-cache in the header.
max-age
Is there any further code?
Commented
May 26, 2020 at 4:56
cacheable=false
in your layout xml? More info here: devdocs.magento.com/guides/v2.3/extension-dev-guide/cache/… Example: meetanshi.com/blog/…