Max-age

The last main thing we need to think about when creating render arrays is how long they should be stored in the cache barring no changes in the underlying data that might invalidate them. This is something that you will probably rarely set and by default it will be cached permanently. More often, however, you will set this cache property to "0" in order to denote that this render array should never be cached. This is when you are rendering something highly dynamic that doesn't make sense to be cached at all.

Get Drupal 8 Module Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.