How to handle caching on a Drupal 8 custom Views access plugin that checks a User's Profile's field value I have a custom Views access plugin that check access against a value in the current User's Profile (entity) field value.

The plugin works but if I change the profile field value the access does not check again until the cache is cleared. I know this is an issue with setting up the cache tags/contexts but I cannot not figure out what is needed so that the cache is cleared when the user profile is updated.

Right now I'm not using any cache tags/contexts in my View access plug and I've tried various combinations without luck. Help!

Current cache functions:

public function getCacheMaxAge() {
    return Cache::PERMANENT;
  }

  /**
   * {@inheritdoc}
   */
  public function getCacheContexts() {
    return ['user'];
  }

  /**
   * {@inheritdoc}
   */
  public function getCacheTags() {
    $profile = \Drupal::entityManager()-&gt;getStorage('profile')-&gt;loadByUser(user_load(\Drupal::currentUser()-&gt;id()), 'employee');    
return $profile-&gt;getCacheTags();
  }
A Views access plugin implements CacheableDependencyInterface. So you probably need to set a tag and a context for the current user in these methods:

  /**
   * {@inheritdoc}
   */
  public function getCacheMaxAge() {
    return Cache::PERMANENT;
  }

  /**
   * {@inheritdoc}
   */
  public function getCacheContexts() {
    return ['user'];
  }

  /**
   * {@inheritdoc}
   */
  public function getCacheTags() {
    return ['user:' . \Drupal::currentUser()-&gt;id()];
  }