So I read that cache contexts and cache tags bubble up to the entire page they're in. Let's say I have a custom page template with 3 sections that are populated in the page's theme preprocess hook:

[A: The Current Time]
[B: The Logged in User Name / A link to login if not logged in]
[C: Node and Taxonomy data]

A and B are very simple and C is very complex and slow. The node/taxonomy data only changes when new content is added, so it also happens to update the least often and the one we'd want to cache the most. B is different between anonymous users and logged in users, and also unique to every user. A is the same for everyone but changes every minute.

Normally, I would have A with a max-age of 60 seconds, B with a 'user' context, and C with the node:id cache tags relevant to what it needs to show (which we invalidate when new content that affects those nodes is added).

It seems to me that including A and B severely limit the ability to cache C, because if the contexts bubble up then B will force the server to keep a cached copy of the page for every different user. And if the lowest max age bubbles up (not sure if this is a thing) then A will force the entire page to be invalidated every minute.

Does that mean that this specific scenario would force Drupal to clear the cache for C every minute? Does it depend on how the page is implemented?

1 Answer 1


The bubbling is for the cache_tags and contexts, so it's related to when the cache on the parent item clears. The parent item will clear based on the children, as the parent has all the child cache tags. It doesn't mean that the children don't cache. They do, but they won't refresh at the same rate as the parent. The parent will potentially clear more often and then rebuild from the cached components.


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.