Skip to main content
edited tags; edited title
Link
4uk4
  • 102.9k
  • 7
  • 176
  • 221

Drupal 8 Cache Block Caching of blocks for anonymous user

Source Link

Drupal 8 Cache Block for anonymous user

I have a little probleme with my cache block.

This is my build function :

return [ '#markup' => time(), '#cache' => [ 'max-age' => 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