How to add a view mode caching dependency in my custom block? I have a block which renders fields of a node. The output of each field is controlled in the view mode settings of the node entity. Now, how can I add caching which is depended on the view mode settings?
Found it out :)

Using entity_get_display to actually load the display view settings of the current node and then just merge the tags:

&lt;?php

public function getCacheTags() {
  if ($node = $this-&gt;getNode()) {
    $cacheTags = Cache::mergeTags(parent::getCacheTags(), array('node:' . $node-&gt;id()));
    $display = $this-&gt;getEntityViewDisplay(); // function which uses entity_get_display
    $cacheTags = Cache::mergeTags($display-&gt;getCacheTags(), $cacheTags);
  }
  else {
    $cacheTags = parent::getCacheTags();
  }

  return $cacheTags;
}