I have a custom block which load some taxonomy terms.
When I made changes to my taxonomies, the block isn't loading the new data (due to the cache). I'm passing all my taxonomy tags to my #cache return
, but nothing append when I reload my page. I still have to drush cr
to see the changes (even tried with taxonomy_term_list
, but didn't work either)
Here's a simplified version of my block :
<?php
**
* @Block(
* id = "custom_block",
* admin_label = @Translation("custom block"),
* category = @Translation("Custom")
* )
*/
class CustomBlock extends BlockBase implements ContainerFactoryPluginInterface {
// properties ...
// constructor...
// create() ...
public function build() {
// ...
$tags = generate_tags_by_id($terms, self::CACHE_TAXONOMY);
// ['taxonomy_term:34', 'taxonomy_term:40' ... ]
return [
/// ...
'#cache' => [
// 'tags' => //$tags,
'tags' => ['taxonomy_term_list'],
]
];
}
}
Here's my container config :
parameters:
http.response.debug_cacheability_headers: false
twig.config:
debug: false
auto_reload: false
cache: true
Also tried to hook on taxonomy update, launch a custom event which invalidate those caches, but not working.
I'm using drupal 9.5.7
http.response.debug_cacheability_headers: true
, do you see 'taxonomy_term_list' in the response headers?build()
?curl --head www.example.com
.