Cache API

Documentation for Cache API in Drupal 8.

Cache API

The Cache API is much improved in Drupal 8. The following sections go into more detail on each feature.

Cache tags

Cache tags = data dependencies

Cache contexts

Cache contexts = (request) context dependencies

Cache max-age

Cache max-age = time dependencies

Cache tags + Varnish

Varnish Cache is a web application accelerator also known as a caching HTTP reverse proxy. Varnish is used on thousands of Drupal sites to

CacheableDependencyInterface & friends

To make dealing with cacheability metadata (cache tags, cache contexts and max-age) easier, Drupal 8 has CacheableDependencyInterface.


This interface lives at the intersection of the Cache API and Responses. Since it is first and foremost a response, that's where the

Access checkers + cacheability

Route access checkers, hook_entity_access() and anything that needs to return an AccessResultInterface object should add the appropriate


Guide maintainers