Two suggestions to improve caching:
In case an entity existsEven if you havedon't want to make a decision to allow or deny access you can return a neutral access result with the correctto add cache datametadata.
The custom cache tag can be replaced by the list tag ENTITY_TYPE_list, which is invalidated automatically when entities are added or deleted.
The resulting code:
public function access(AccountInterface $account) {
if ($entity_does_not_exist) {
return AccessResult::forbidden()->addCacheTags(['my_entity_list']);
}
return AccessResult::neutral()->addCacheTags(['my_entity_list']);
}
postDelete() and postSave() are no longer necessary.