Drupal core also provides a mechanism here that allows us to say 'this piece of cache data relies on this other piece of cache data'. Note that HOOK_menu_local_tasks_alter provides a helper for cacheability, the third param of $cacheability. Additional use of cache tag for a specific user to say: 'once this is cached, when this user entity changes, go regenerate the local tasks for this user'.General cache contexts that says 'this menu content now relies on the user', eg.Tags define what object the cache depends on. These contexts may be the user permissions, language settings or URL parameters. They're sets because a single cache item can depend on (vary by) many cache contexts. Cache contexts are passed around in sets (order doesn't matter) of strings, so they are typehinted to string. For example, one page for two different users may look different. A cache context is a string that refers to one of the available cache context services (see below). I believe the issue is not so much the creation of the cacheable metadata, its seems that your hook_menu_local_tasks_alter is altering content that doesn't know it now relies on the user. Context is a cache dependency on context, that creates variations when the render arrays are being generated. Instead of providing a custom cache context, you should be able to use the default cacheability provided by core. Code snippet that can use to display all current cache contexts for your site in drupal 8.
0 Comments
Leave a Reply. |