How to remove the default cache tags on a block? Here's what I'm noticing:


I set the cache array to what I want it to be in my block
It propagates up to BlockViewBuilder.php and gets put into the $build's content array
There is still a #cache array on the $build itself, which by default has three contexts:
array('languages:language_interface', 'theme', 'user.permissions')


I want to get rid of the languages and user.permissions contexts for my block, because they shouldn't affect its content and I don't want the two contexts to have inconsistent data, but setting my block's contexts won't affect the ones set by the top level $build object.  Is there a way for me to do that?

It looks like CacheableMetadata::createFromRenderArray() will try to merge the two #cache arrays, but from the way it's doing it, it seems it will grab unique values from the two arrays.  Is there a place where I can remove the bad contexts?
Nope, you can't really opt out of those.

They are defined as required cache contexts in services.yml. So even if you'd manage to remove them, they are added in Renderer.php.

You could change that globally, but you have to be aware of the risks as it is likely that not every contrib/custom code is adding the user.permissions cache context when required, so we decided to make that a default so that at least that kind of cache/acess separation is enforced.