I try to understand how drupal core cache tags is add :

this is my tags on my home when i am logged :

node:121 node:158 node:23945 node:23946 node:43328 node:491 node:514 node:59139

It's good, this relate my node on my home.

But if i check my home in anonymous, this is what i get :

node:115 node:121 node:153 node:158 node:172 node:18240 node:18244 node:18256 node:23945 node:23946 node:307 node:43328 node:45 node:491 node:514 node:59139 node:59143 node:59144 node:59145 node:59146 node:59147 node:59148 node:59149 node:59193 node:59197 node:59239 node:59269 node:59283 node:59289 node:59293 node:59522 node:59770 node:60375 node:60390 node:60415 node:60418 node:60480 node:60542 node:60606 node:60616 node:60727 node:60785 node:60793 node:60819 node:60824 node:60827 node:60873 node:66011 node:66019 node:66026 node:66028 node:66030 node:66036 node:66039 node:8555 node:8561

And most of this tag is wrong for the home page, how drupal find them ?

I know there is a cache context, but its the core who add this tags


After some debug i got some answer :

Context : my menu is render by core block menu in region.

For anonymous user, drupal add the tag node:id for every item in my menu.

if i remove the block, all node:id tag is removed.

So i have 2 solutions :

  • For all user who hasn't bypass node access permission drupal add every tag from the menu block render.

So i can try to fix the access check on the menu

  • Remove the drupal core block menu from region and build my own block programmatically and load my menu inside with menu_tree service.

i have try the second point and since its not drupal who render my custom block, tags is not add.

But for me the best way is to find a way for fix the check access.

i can't clear all the node in the cache when someone edit a node in the menu.

For that i want use the tag menu_link_item but not the node:id...

  • With browser strip/disable all CSS, maybe they are hidden?
    – No Sssweat
    Apr 23, 2020 at 16:35
  • its in the header of the request where i see this tag : X-Cache:
    – Kevin
    Apr 23, 2020 at 16:36
  • I know, but perhaps they are getting added to the header because they actually exist, but are just hidden from display.
    – No Sssweat
    Apr 23, 2020 at 16:38
  • um i ll check that
    – Kevin
    Apr 23, 2020 at 16:38
  • You can strip all CSS with this addon, might as well disable JavaScript too just in case.
    – No Sssweat
    Apr 23, 2020 at 16:40

1 Answer 1


You don't need to render a node to bubble up its cache tag. There are other reasons, for example access checks, which heavily depend on the current user. A negative access check still could bubble up the node cache tag when the result depends on field values. So the tags of not rendered nodes could be unpublished nodes in views or menus. When you publish one of those nodes you want that the page gets refreshed to include the now published node.


You can replace the core menu block with a custom menu block, see

Rendering menus

Once you have created menus (that contain menu links), you want to render them. Drupal provides a block (Drupal\system\Plugin\Block\SystemMenuBlock) to do so.

However, perhaps you have more advanced needs and you're not satisfied with what the menu blocks offer you. If that's the case, you'll want to:



By doing so you have the options to not use access checks at all, add your own version of an access check tree manipulator or use the core one and remove the cache tags from the tree access objects afterwards with AccessResult::resetCacheTags

  • oh yes i have check some nid and yep there are some node unpublished
    – Kevin
    Apr 23, 2020 at 19:00
  • Ok but i can't find any relation between the node and the other nid in the tag... or this tags are on other page too ? with no relation ?
    – Kevin
    Apr 23, 2020 at 19:06
  • You use the menu system? Menu entries are also checked for access to the target before displayed. And there are probably dozens of other reasons why node tags could bubble up. Depends on how you have configured your site and which modules you use.
    – 4uk4
    Apr 23, 2020 at 19:33
  • yes i use the menu system, but node in the header is accessible to anonymous user, i ll try to debug, its not easy to trace where the tag come from. As always thank for your time and your help @4k4
    – Kevin
    Apr 23, 2020 at 19:36
  • After analyse, all tags is add by the menu, all my node in any menu got they tag add to the header of the request, i'am looking for a way for remove this node tag, i have another tag when user change the menu.
    – Kevin
    Apr 24, 2020 at 20:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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