Quoting Wim Leers in #2475749-2: Allow to set #cache metadata in hook_page_attachments():
In a follow-up, we should make all
hook_page_attachments(),hook_page_attachments_alter(),hook_page_top()andhook_page_bottom()implementations set the right cacheability metadata.For example,
quickedit_page_attachments()only adds its asset library if the current user has the right permission (vary by the'user.permissions'cache context) and it's not an admin route (no cache context for that yet).
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | hook_page_*-2478393-1.patch | 8.93 KB | wim leers |
Comments
Comment #1
wim leersAlso updates a cache context and adds a new one, so https://www.drupal.org/developing/api/8/cache/contexts needs to be updated.
Comment #8
bradjones1Bumping target version, this is surprisingly pertinent in the case of modules like Google Analytics and Olark chat, among probably many others, that set per-user information in drupalSettings but do not account for cacheability.
Comment #19
ksenzeeJust today I had to work around the absence of a route.isAdmin cache context.