Render element and caching I'm a little bit confused with hide() documentation.
It says:


  The first time render() or drupal_render() is called on an element
  tree, as each element in the tree is rendered, it is marked with a
  "#printed" flag and the rendered children of the element are cached. Subsequent calls to render() or drupal_render() will not traverse the
  child tree of this element again: they will just use the cached
  children. So if you want to hide an element, be sure to call hide() on
  the element before its parent tree is rendered for the first time, as
  it will have no effect on subsequent renderings of the parent tree.


First of all, I want to say I understand that hide() allow to avoid rendering of a specific element.

But documentation says more :


By talking about caching element as it is the default behaviour. For me, if #cache property is not defined for an element, when rendering the element will be not be cached.
And for me also, subsequent calls to drupal_render() will not use the cached element, because #printed property will be checked before trying to get the cached element (#printed=TRUE means return '';) .


I want to get your explanation about this.
Render arrays are trees. If you hide() the subtree P1.P2.P3.P4, it's stil possible for a supertree (P1.P2 or P1.P2.P3) to have caching enabled (i.e. have #cache set).

Also note that just having #cache set does not mean that the subtree with that element as a root does not get cached per se. Only when #cache[keys] is set is render caching triggered. #cache can also just contain cacheability metadata (tags, contexts, max-age) describing the cacheability of that subtree.

See https://www.drupal.org/developing/api/8/render/arrays/cacheability.