One of the last blocks that needs to become cachable is SystemBreadcrumbBlock
.
Updated: Comment #0
Problem/Motivation
The breadcrumbs block is currently not cacheable at all.
Proposed resolution
Cache breadcrumbs on a per-URL, per-role, per-language basis. This, combined with the fact that proper cache tags should be set by the used breadcrumb builder (BreadcrumbBuilderInterface::build()
), would ensure that we can cache the breadcrumb block forever, since any change that could affect the breadcrumbs to be rendered would invalidate the corresponding render cache entries.
Unfortunately, all of the breadcrumb classes don't even comply with the interface they're implementing: they're returning an array of rendered links, not a render array! Therefore, it is currently impossible to set cache tags!
Remaining tasks
Allow breadcrumb builders to bubble up cache tags.
User interface changes
None.
API changes
None.
Comment | File | Size | Author |
---|---|---|---|
#1 | cacheable_breadcrumbs-2232609-1.patch | 2.22 KB | Wim Leers |
Comments
Comment #1
Wim LeersComment #2
jibranMaybe we can create a sub task for this issue and discuss. I can help in fixing the issue.
Comment #3
Wim LeersComment #4
dawehnerDo we really want to cache it, even we know already that its existence depends on access? These links can use any route access checkers ...
This certainly will be replaced by #2314599: Use title/url instead of l() for building breadcrumb
Comment #5
dawehnerI really hope we don't treat performance over security here. In case we do, have fun with chx :P
Comment #6
Wim LeersSorry, this shouldn't be marked as needing review. That's why I removed the "sprint" tag. This was only a very rough, extremely outdated, first pass :)
Low priority for now.
Comment #7
Wim Leers#2287071: Add cacheability metadata to access checks allows this one to actually be solved! :)
Comment #8
joelpittetIf we want a text, aka non-link breadcrumb, is that do-able?
Comment #9
fgm@joelpittet this is worked on in #2345801: template_preprocess_breadcrumb() assumes all breadcrumbs are \Drupal\Core\Link objects.
Comment #10
joelpittet@fgm merci bien;)
Comment #11
jibranI think we can re-evaluate this once #2483183: Make breadcrumb block cacheable is in and decide whether it's a duplicate or maybe we can further improve the subsystem.
Comment #12
Wim LeersAFAICT this is a duplicate of #2483183: Make breadcrumb block cacheable.