diff --git a/core/lib/Drupal/Core/Render/PlaceholderGenerator.php b/core/lib/Drupal/Core/Render/PlaceholderGenerator.php index a6c4a2343f6febcd212030d7124a8e757160b8a2..442ad6b5f863b445e8ca141aa3d5f3b1185a20fa 100644 --- a/core/lib/Drupal/Core/Render/PlaceholderGenerator.php +++ b/core/lib/Drupal/Core/Render/PlaceholderGenerator.php @@ -49,19 +49,19 @@ public function canCreatePlaceholder(array $element) { * {@inheritdoc} */ public function shouldAutomaticallyPlaceholder(array $element) { + // Auto-placeholder if the max-age, cache context or cache tag is specified + // in the auto-placeholder conditions in the 'renderer.config' container + // parameter. $conditions = $this->rendererConfig['auto_placeholder_conditions']; - // Auto-placeholder if max-age is at or below the configured threshold. if (isset($element['#cache']['max-age']) && $element['#cache']['max-age'] !== Cache::PERMANENT && $element['#cache']['max-age'] <= $conditions['max-age']) { return TRUE; } - // Auto-placeholder if a high-cardinality cache context is set. if (isset($element['#cache']['contexts']) && array_intersect($element['#cache']['contexts'], $conditions['contexts'])) { return TRUE; } - // Auto-placeholder if a high-invalidation frequency cache tag is set. if (isset($element['#cache']['tags']) && array_intersect($element['#cache']['tags'], $conditions['tags'])) { return TRUE; } diff --git a/core/lib/Drupal/Core/Render/PlaceholderGeneratorInterface.php b/core/lib/Drupal/Core/Render/PlaceholderGeneratorInterface.php index 89802a2efda72b70dbdb4f5c72589e7dc545c6cc..224bcbf5599e84270b76eea02a28e81d449d9b38 100644 --- a/core/lib/Drupal/Core/Render/PlaceholderGeneratorInterface.php +++ b/core/lib/Drupal/Core/Render/PlaceholderGeneratorInterface.php @@ -35,6 +35,11 @@ public function canCreatePlaceholder(array $element); /** * Whether the given render array should be automatically placeholdered. * + * The render array should be placeholdered if its cacheability either has a + * cache context with too high cardinality, a cache tag with a too high + * invalidation rate, or a max-age that is too low. Either of these would make + * caching ineffective, and thus we choose to placeholder instead. + * * @param array $element * The render array whose cacheability to analyze. *