Tip: invalidate cache tags on entity CRUD actions.
/**
* Implements hook_entity_insert().
*/
function bundle_cache_tags_entity_insert(EntityInterface $entity) {
$cache_tag = "{$entity->getEntityTypeId()}_list:{$entity->bundle()}";
Cache::invalidateTags(array($cache_tag));
}
<?php
/**
* Implements hook_entity_presave().
*/
function bundle_cache_tags_entity_presave(EntityInterface $entity) {
$cache_tag = "{$entity->getEntityTypeId()}_list:{$entity->bundle()}";
Cache::invalidateTags(array($cache_tag));
}
/**
* Implements hook_entity_delete().
*/
function bundle_cache_tags_entity_delete(EntityInterface $entity) {
$cache_tag = "{$entity->getEntityTypeId()}_list:{$entity->bundle()}";
Cache::invalidateTags(array($cache_tag));
}