Disable cache for specific page | Drupal 8

Disable cache for specific page

Submitted by editor on Sun, 11/08/2020 - 18:51
Question

How to Disable page cache for specific page on Drupal 9 and Drupal 8 ?

Syntax:

\Drupal::service('page_cache_kill_switch')->trigger();

 

Example on a controller:

public function testPage() {
  \Drupal::service('page_cache_kill_switch')->trigger();
  return [
    '#markup' => time(),
  ];
}

 

Comments

Add new comment

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.