Summary
In this chapter, we covered the main aspects of caching that any Drupal module developer needs to be familiar with. We introduced some key concepts and talked about the two main types of caching—Internal Page Cache (used for anonymous users) and Dynamic Page Cache (used for authenticated users).
We dug deeper into cacheability metadata, which is probably the most important and common thing we need to understand. It’s imperative to use this properly so that all the render arrays we build are cached and invalidated correctly. We also saw how block plugins have specific methods we can use to define their cacheability metadata and how access results should also receive cacheability dependencies, as needed. Stemming from this, we also explored lazy builders and auto-placeholdering strategies, which allow us to handle highly dynamic components while maintaining good cacheability overall.
Lastly, we looked into using the Cache API ourselves in order to store, read...