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->cache->get($cache_key)) {
return $cache->data;
}
// $content = request...
$this->cache->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.
Required by: Acquia Purge (disabled), Lightning
. I just uninstalled it.