Caching of blocks for anonymous user I have a little probleme with my cache block.

This is my build function : 

return [
  '#markup' =&gt; time(),
  '#cache' =&gt; [
    'max-age' =&gt; 10
  ]
];


I found this specification for block cache. 

  /**
   * {@inheritdoc}
   */
  public function getCacheMaxAge() {
    return 20;
  }


Because in parent class we have $max_age = Cache::PERMANENT;

So, when I'm connected my rendered cache refresh each 10 seconds.
But when I'm a anonymous user my rendered block never change.

I don't find the solution.

Big pipe isn't install, I have aggregations css and js but I don't have max age in admin/config/development/performance.

Finnaly I want a block without cache because this block will rendered message with close button. When the user click on the close button, I set a cookie for return an empty bluid in my block.

Do you have an idea ?

Thank you
You don't have to worry about the values which are set for cache max-age in other places, because when these are merged the lower time that you have set wins.

But you can't control with max-age the page cache for anonymous users. You have to use \Drupal::service('page_cache_kill_switch')-&gt;trigger(); in the block build method to disable the page cache or you can simply uninstall the module Internal Page Cache if you plan to use the block on all pages.


  but I don't have max age in admin/config/development/performance


You should set this to the same max-age to control the browser cache and proxies.