The feeds (at least for Facebook) to appear for the anonymous users I need to clear all caches. It works normally to logged in users. I tried to set the cache time on or off but does not to help. I can also see from code that the default is set to one hour and how the caching is implemented. We use also Purge + Varnish purger + Core tags queuer + Varnish Purger Tags on the site so the cache invalidation does not work properly with Varnish cache when it fetches/loads the new content.
How I understood this is that the caching is not implemented properly. Fetching is done by:
public function getData() {
$cid = 'socialmediafeed:facebook';
$data = NULL;
if ($this->config->get('cache_enable') && $cache = \Drupal::cache()->get($cid)) {
$data = $cache->data;
$this->socialmediafeeds = $data;
}
else {
$this->fbposts();
\Drupal::cache()->set($cid, $this->socialmediafeeds, strtotime('+1 hour'));
}
return $this->socialmediafeeds;
}
Should be something like:
$cache_backend->set(
$cid, $data, Cache::PERMANENT, ['node:5', 'user:7']
);
See: "How" from https://www.drupal.org/docs/8/api/cache-api/cache-tags
I have not much experience about implementing caching in D8 module so am I on the right track or understood this totally wrong? I hope I have so someone could just tell me how to invalidate the Varnish cache from the Purger settings. :)
Comments