Commit 76525d81 authored by alexpott's avatar alexpott
Browse files

Issue #2564577 by snehi, borisson_, Wim Leers, r_sharma08, lauriii: Improve...

Issue #2564577 by snehi, borisson_, Wim Leers, r_sharma08, lauriii: Improve comments on PlaceholderGeneratorInterface::shouldAutomaticallyPlaceholder() and DynamicPageCacheSubscriber::shouldCacheResponse()

(cherry picked from commit df41f701)
parent 42cad40a
......@@ -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;
......@@ -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.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment