diff --git a/pantheon_advanced_page_cache.services.yml b/pantheon_advanced_page_cache.services.yml index 266c239..6777fd0 100644 --- a/pantheon_advanced_page_cache.services.yml +++ b/pantheon_advanced_page_cache.services.yml @@ -4,6 +4,7 @@ services: arguments: ['pantheon_advanced_page_cache'] pantheon_advanced_page_cache.cache_tags.invalidator: class: Drupal\pantheon_advanced_page_cache\CacheTagsInvalidator + arguments: ['@request_stack'] tags: - { name: cache_tags_invalidator } pantheon_advanced_page_cache.cacheable_response_subscriber: diff --git a/src/CacheTagsInvalidator.php b/src/CacheTagsInvalidator.php index 139e67a..7706626 100644 --- a/src/CacheTagsInvalidator.php +++ b/src/CacheTagsInvalidator.php @@ -3,16 +3,39 @@ namespace Drupal\pantheon_advanced_page_cache; use Drupal\Core\Cache\CacheTagsInvalidatorInterface; +use Symfony\Component\HttpFoundation\RequestStack; /** * Cache tags invalidator implementation that invalidates the Pantheon edge. */ class CacheTagsInvalidator implements CacheTagsInvalidatorInterface { + /** + * The request stack. + * + * @var \Symfony\Component\HttpFoundation\RequestStack + */ + protected $requestStack; + + /** + * Construct. + */ + public function __construct(RequestStack $request_stack) { + $this->requestStack = $request_stack; + } + /** * {@inheritdoc} */ public function invalidateTags(array $tags) { + $do_not_run_urls = [ + // There is a weird interaction with metatag that clear local_tasks key + // and therefore lots of cached pages. + '/core/install.php', + ]; + if (in_array($this->requestStack->getCurrentRequest()->getBaseUrl(), $do_not_run_urls)) { + return; + } if (function_exists('pantheon_clear_edge_keys')) { pantheon_clear_edge_keys($tags); }