Taxonomy term not getting invalidated I'm learning the new caching system. For testing purposes I have turned off Page Cache and Dynamic Page Cache.

I've set a custom block with the following:

&lt;some code&gt;
$build_array = $view_builder-&gt;view($referenced_entity, self::VIEW_MODE, self::LANG_CODE);

$build_array['#cache']['contexts'][] = "route";
$build_array['#cache']['keys'] = ['mymodule_panels_blocks','taxonomy_term', $term-&gt;id()];


This is for displaying an eck entity with an image that is attached to a taxonomy term.

The expected behavior is that when I point the term to a different eck entity, the taxonomy term is invalidated.

When I check the full list of tags (using http.response.debug_cacheability_headers: true) I see my taxonomy term listed (taxonomy_term:209).

So it would seem I'm all set up. Yet when I change the eck entity to a new one, click Save, then click View, I see the old image still.

When I flush the render cache, I see my new image.

Isn't the invalidation of the taxonomy term automatic when the term is saved? Or do I have to write a hook to invalidate the taxonomy term when it changes?
Yes, the invalidation is automatic. From the debugging you have done so far you only know that the tag is somewhere on the page, but you don't know where it is and obviously it is not where you want it to be. Look in the database table cache_render. Clear the cache, so that it is emptied. Now request the page with the block and check for all cached elements the column tags.

By the way, you don't need to set cache keys on a block, because blocks do this automatically and for the problem here it's confusing, because the taxonomy id you set in the keys is not invalidated.