Skip to main content
4 of 7
improved grammar and formatting
avpaderno
  • 97.9k
  • 15
  • 164
  • 284

You should use code similar to the following one.

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

}

Recently, Add #cache[max-age] to disable caching and bubble the max-age was committed.
When $build['#cache']['max-age'] is not set, permanent cache is assumed. To indicate that a render array should not be cached at all, set $build['#cache']['max-age'] to 0 (i.e. 0 seconds); to indicate that a render array should be cached only for a limited period, e.g. 5 minutes, set $build['#cache']['max-age'] to 300 (i.e. 5 * 60 seconds).

After, clear the cache.

Zuzuesque
  • 1.4k
  • 12
  • 15