Last updated May 13, 2019
Module Development8.9.x/9.0.x

A lot of the processes that Drupal performs when responding to a request are cached in order to increase performance. Creating the HTML for the page that a user sees, or the JSON response to a REST request, can require thousands of operations. Some operations are time consuming, memory heavy, CPU intense, or all three. By performing the operation once, and then caching the result for next time, subsequent requests can be fulfilled faster. In order to make it easier to store, retrieve, and invalidate cached data Drupal provides cache-related services you can use in your code. Drupal also lets you provide information about the cacheability of data to the Render API to improve the performance of rendering a page.

In this tutorial we'll:

  • Get an overview of the terms and concepts you should be familiar with when working with the Cache API
  • Point to additional resources for more information about how to perform specific tasks with the Cache API

By the end of this tutorial you should be able to define the concepts of bubbling and cache invalidation, and know how cache keys, tags, context, and max-age are used to provide cacheability metadata for items.