diff --git a/flag/flag.module b/flag/flag.module
index 75fd868..7eead6f 100644
--- a/flag/flag.module
+++ b/flag/flag.module
@@ -318,6 +318,10 @@ function flag_entity_view(array &$build, EntityInterface $entity, EntityViewDisp
 
   $build['#cache']['contexts'][] = 'user.permissions';
 
+  if (empty($build['#cache']['tags'])) {
+    $build['#cache']['tags'] = [];
+  }
+
   // Get all possible flags for this entity type.
   $flag_service = \Drupal::service('flag');
   $flags = $flag_service->getFlags($entity->getEntityTypeID(), $entity->bundle());
