I have a view display block that needs to be updated every 8 hours. I tried Views Custom Cache Tag module https://www.drupal.org/project/views_custom_cache_tag but I could not make it work. I set my tag for the view block display and then invalidate this tag with the each API call, but the block does not get updated. I am looking for programmatical solution of flushing the cache of view blocks without changing the rest of the content.

  • Yes, see below: use Drupal\Core\Cache\CacheTagsInvalidatorInterface; $tags = ['view:catchme-tag']; $this->cacheTagsInvalidator->invalidateTags($tags);
    – JetSet
    Commented Nov 14, 2019 at 19:11
  • I write in into my service class.
    – JetSet
    Commented Nov 14, 2019 at 19:13
  • I think this issue with Views Custom Cache Tag module is relevant drupal.org/project/views_custom_cache_tag/issues/2971568
    – JetSet
    Commented Nov 14, 2019 at 19:15
  • I also invalidate the tag manually with drupal console, but it does not update the block. I use drupal cti view:catchme-tag, it does invalidate it
    – JetSet
    Commented Nov 14, 2019 at 19:18
  • 1
    @Jdrupal, it's hard to follow the discussion when you delete comments that other refer to. JetSet, concerning the original question, you can invalidate pages cached for anonymous users through cache tags. Can you confirm the cached page contains the tag you want to invalidate by checking the http.response.debug_cacheability_headers. You can enable them via development.services.yml and then check the header in the browser debugging tools. If not, then something is blocking the cache tag set in the view bubbling up to page level and you need to check each cache entry in the database all the way.
    – 4uk4
    Commented Nov 14, 2019 at 20:26


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.