I have a custom blocks that displays results based on an entity query. For some pages the correct result is blank, and I want to hide the block.
When a return an empty array from the block's build()
method it appears to cache more or less forever.
If I return a render array that just contains #cache
values will that get honored, or will the lack of content invalidate those tags some place another the way?
if (empty($relatedContent)) {
return [
'#cache' => [
'contexts' => ['url'],
'tags' => ['node_list'],
],
];
}
For what it's worth, I've been testing the idea and I'm running into issues, but it's not clear yet if that's related to this or some other problem.