Adding a cache tag to an entity view display doesn't do anything? I wrote a module that implements hook_entity_view_display_alter(). I modify the display settings of one of the fields depending on some configuration setting of my module.

/**
 * Implements hook_entity_view_display_alter().
 */
function ps_events_entity_view_display_alter(EntityViewDisplayInterface $display, array $context) {
  // Change the date formats of the date field on the full page display based
  // on configured settings.
  if ($context['entity_type'] === 'node' &amp;&amp; $context['bundle'] === 'ps_events' &amp;&amp; $context['view_mode'] === 'ps_full_content_no_lb') {
    $eventsSettings = \Drupal::config('ps_events.settings');
    $dateComponent = $display-&gt;getComponent('field_ps_events_date');
    if ($dateComponent) {
      $dateComponent['settings']['date_format'] = $eventsSettings-&gt;get('detail_page_date_format_day_and_time');
      $display-&gt;setComponent('field_ps_events_date', $dateComponent);
      $display-&gt;addCacheTags(['config:ps_events.settings']);
    }
  }
}


However, the cache tag I add doesn't seem to have any effect. When I inspect the cache_render table and look at the entry for this entity view display, my cache tag is not present. Changing the settings of my module does not clear the cache for this entity view display.

As a workaround, I also implement hook_entity_view_alter(), which operates on the complete render array of the entity view display. I add the cache tag here and it works.

This seems like either a bug in core, or maybe I misunderstand the purpose of cache tags on the EntityViewDisplay object?
For that to work, core would have to use getCacheTags() from that config entity, which it doesn't do.

I'm not sure if that should be changed, core currently does not add the cache tags of that entity on purpose, instead it it invalidates the generic {$entity_type}_ cache tag on saving such an entity in \Drupal\Core\Entity\Entity\EntityViewDisplay::postSave(). Consdering that this changes only very infrequently once a site is live, this is more performant as there are fewer cache tags to check on each request.