Caching in Drupal 8 is great, but documentation is thin (at this time) on using cache tags for render arrays in Drupal 8.
I have some code that basically generates a list of node teasers, say for content types "books" and "magazines". I'm caching the list to speed things up. I would like to refresh the list every time a "book" or "magazine" is added/deleted/edited. So I have a render array that looks like this:
$build = array( '#type' => 'markup', '#markup' => $sMarkup, '#cache' => [ 'keys' => ['home-all','home'], 'tags'=> ['node_list'], // invalidate cache when any node content is added/changed etc. 'max-age' => '36600', // invalidate cache after 10h ], );
By using the cache tag ['node_list'], the cache invalidates properly when content is added or edited, but will also invalidate when a content type not being listed here is changed, say "casette".
What cache tags can I use to limit the invalidation to when only "book" or "magazine" is added/changed/deleted? I've tried using: ['book_list','magazine_list'] but that doesn't work.