Invalidating render cache items for anonymous? We have a certain content type in Drupal 8 that has a small grid of data on it that is populated from an API call when the node view is being built.

In that call, I am checking for cache and setting cache instead of talk to the API every request:

if ($cache = $this-&gt;cache-&gt;get($cache_key)) {
  return $cache-&gt;data;
}

// $content = request...

$this-&gt;cache-&gt;set($cache_key, $content, REQUEST_TIME + 3600, ['mymodule']);


Where $cache_key is just mymodule:remote_id:subscription_id. My default cache bin is handled via Memcache.

The Drupal page cache time is set to 30 minutes, and Varnish sits in front of it for anonymous traffic.

I am noticing that even though my custom cache data is set for an hour timer, and the Drupal cache is set for 30 minutes, users are able to see data from 3 days ago but I am not sure how. As soon as I go view the site (authenticated) and refresh, the data updates.

I tried backtracking this but nothing jumped out as missing, perhaps other than some cache tags I might need to add. Even still, the render object is what is being shown from cache, which the data is a part of before it is cached, not the cached data item itself.

System cron is running every hour. Shouldn't it purge invalidated cache as part of system_cron? 

Edit: I switched my local from Memcache back to the default cache (MySQL) and noticed render cache items all have an expiration of -1.

At what point are entity render cache items invalidated? I feel like that might be my issue, but not sure how to address it.
the max-age (maximum age) ... defaults to &quot;permanently (forever) cacheable&quot;
...
Cache contexts, tags and max-age must always be set, because they affect the cacheability of the entire response. Therefore they &quot;bubble&quot;: parents automatically receive them.
Cache keys must only be set if the render array should be cached.

from https://www.drupal.org/docs/8/api/render-api/cacheability-of-render-arrays
Render arrays are cached indefinitely by default and setting the page cache expiration time doesn't change the cacheability metadata of render arrays in general. As on the linked page above, ideally you do something like:
// Merges the cache contexts, cache tags and max-age of the config object 
// and user entity that the render array depend on.
$renderer-&gt;addCacheableDependency($build, $config);
$renderer-&gt;addCacheableDependency($build, \Drupal\user\Entity\User::load($current_user-&gt;id())); 

But this doesn't work here because the data lives outside of Drupal - or more specifically, if you add anything that doesn't implement Drupal\Core\Cache\CacheableDependencyInterface as a dependency, the render array is marked as non-cacheable and it bubbles up: see Drupal\Core\Cache\RefinableCacheableDependencyTrait::addCacheableDependency().
So in this case I think you just have to set the max-age yourself.