How to purge cached content every day via cache tag?
Here is the code that flush cache on first hit of a day:

  public function build() {
    ...
    ...
    ...
    $this-&gt;handleCacheTag($build['#cache']['tags']);
  }


  protected function handleCacheTag(&amp;$tags) {
    // Get the current date number.
    $current_date_number = date('z');
    $last_date_number = \Drupal::state()-&gt;get('module_name.foo.date_counter', $current_date_number);
    // If last date in settings is different from current day, invalidate
    // tags.
    if ($last_date_number &lt; $current_date_number) {
      $invalid_tags = range($last_date_number, $current_date_number);
      array_walk($invalid_tags, function(&amp;$invalid_tag){
        $invalid_tag = 'foo:date.' . $invalid_tag;
      });
      Cache::invalidateTags($invalid_tags);
    }
    \Drupal::state()-&gt;set('module_name.foo.date_counter', $current_date_number);
    $tags[] = 'foo:date.' . $current_date_number;
  }