Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

2
  • That works, but wouldn't the "correct" way be to define the getCacheMaxAge method? Commented Jun 24, 2019 at 18:33
  • 1
    @Jdrupal, "correct" would be to place the cache metadata as close as possible to the data it is connected to. If you put data in a render array then place the cache metadata in the same render array. For nested arrays you can bubble up metadata from multiple places. The block plugin implements the same cache interface like any other plugin type and the methods to return cache metadata are mainly used in plugins which don't return rendered output. Commented Jun 24, 2019 at 21:15