Why do we invalidate cache tags instead of clear cached items with those tags? Under what conditions would the invalidated cache be returned?

  • I think that multiple DELETE queries will take much longer than a single update query.
    – Eyal
    Commented Apr 14, 2017 at 18:33

1 Answer 1


See my presentation on Drupal 8 Caching about that topic: https://md-systems.github.io/drupal-8-caching/#/6/6 for how you can still get invalid items. And https://md-systems.github.io/drupal-8-caching/#/6/5 on how cache tag invalidation works.

The reason why cache tags invalidate instead of delete is scalability. Invalidating a cache tag does not require us to touch each single cache entry, we just need a single update query to increase the invalidation counter that is checked when cache entries are loaded. Common cache tags like renderered, image style cache tags and other frequently used cache tags could be on tens or hundreds of thousands of cache entries, deleting them all at once would take a very long time on MySQL and other cache backends like Memcache have no API to do do something like that at all.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.