Domanda

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?

È stato utile?

Soluzione

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.

Magento 2 remove cache from Block class

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a magento.stackexchange
scroll top