Skip to main content
Improving the answer
Source Link
Rafael Corrêa Gomes
  • 13.7k
  • 14
  • 91
  • 181

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

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();
    ...
}

Magento 2 remove cache from Block class

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

added 61 characters in body
Source Link
Rafael Corrêa Gomes
  • 13.7k
  • 14
  • 91
  • 181

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();
    ...
}

Magento 2 remove cache from Block class

You can implement the HTTP class and call the method setNoCacheHeaders, as you can see below.

use Magento\Framework\App\Response\Http;


$this->response->setNoCacheHeaders();

Magento 2 remove cache from Block class

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();
    ...
}

Magento 2 remove cache from Block class

Source Link
Rafael Corrêa Gomes
  • 13.7k
  • 14
  • 91
  • 181

You can implement the HTTP class and call the method setNoCacheHeaders, as you can see below.

use Magento\Framework\App\Response\Http;


$this->response->setNoCacheHeaders();

Magento 2 remove cache from Block class