![]() ![]() See for an example of a cache context, which itself depends on other data, which can be invalidated. Code snippet that can use to display all current cache contexts for your site in drupal 8. In getCacheableMetadata you would just return the node cacheable metadata and the user.roles. Same name and namespace in other branches. If caneditnode is given as cache context without context it could just throw an Exception or fallback to as that is what it depends on. Whenever this cache context is used, your handler is checked and needs to return the right information based on the given Context. 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. Under Reactions the Add Reaction pull-down menu will give you a new option, Cache. Navigate to Administration Structure Context (admin/structure/context) and click on a context or create a new one. You create a custom cache context (see for many examples), which itself is dependent on the and cache context (as it needs to check the node).Į.g. Generate cache for a context specifying the module, the context name and its class drupal generate:cache:context -modulemodulename. If you are using an external cache you don't need to enable page caching. A cache key is not the right solution as dynamic_page_cache won't vary on the right things.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |