I want Node breadcrumbs to be updated when the content is updated, so I added the following code to my breadcrumb generation class:

// Set cache tags
$node_cache_tag = 'node:'.$node->id();

My concern is that this is a bad idea for sites with a lot of content (300,000+). I saw this post https://www.drupal.org/node/2891281 and noted that the default cache row limit is 5,000. Would the above code be an issue with over 300,000 nodes? Should I cache the breadcrumbs based on the taxonomy term that created the breadcrumbs (~1300 terms)?


First of all you should add tags of all nodes/terms you use to build the breadcrumb. You can't set too many tags, because a tag doesn't influence how many cache entries are stored.

This is only a problem you have by adding cache contexts. By default this is url.path.parent. But if you use for example the title of the current node, then you need url.path. When you have 300.000 nodes this can indeed make caching quite useless and you could consider setting a cache max-age of 0 to disable caching. Perhaps by doing this you also benefit from lazy loading of the breadcrumb block by Big Pipe, if this is for logged-in users, I've never tried this. And for anonymous users pages are cached for each path anyway.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.