How to purge cached content every day via cache tag? Drupal 8 page has a day specific element which is valid for current day. I would like to add a cache tag so that it can be purged in varnish/fastly periodically. Is there a way to invalidate cache tag periodically on Drupal8? 

Here is few FAQs/As:


Why can't use max-age?


max-age can be used, but it's page level header which can get quite confusing when more than one component try to set it. Cache tag is kind of self-contained to the component.


Why don't run cron?


Trying to avoid explicit cron/job to do this as it's environment specific.
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;
  }