Commit 9fd27b3a authored by Jakob P's avatar Jakob P
Browse files

Partial Revert of Issue #2976480: Do not send Cache-Tags header if Cache-control: no-cache.

parent 635c2f1c
Loading
Loading
Loading
Loading
+2 −13
Original line number Diff line number Diff line
@@ -51,19 +51,8 @@ class CacheableResponseSubscriber implements EventSubscriberInterface {

    // Only set any headers when this is a cacheable response.
    $response = $event->getResponse();

    // Cache tags should be injected only when the response is cacheable. It is
    // cacheable when dynamic_page_cache module (if enabled) says so.
    // Alternatively, if dynamic_page_cache module is uninstalled, then we
    // fallback on testing that at least 'no-cache' cache directive is not
    // present in the response headers.
    $cacheTagsNeeded = $response instanceof CacheableResponseInterface;
    if ($response->headers->has('X-Drupal-Dynamic-Cache')) {
      $cacheTagsNeeded = $cacheTagsNeeded && $response->headers->get('X-Drupal-Dynamic-Cache') !== 'UNCACHEABLE';
    }
    $cacheTagsNeeded = $cacheTagsNeeded && !$response->headers->hasCacheControlDirective('no-cache');

    if ($cacheTagsNeeded) {
    if ($response instanceof CacheableResponseInterface
      && !$response->headers->hasCacheControlDirective('no-cache')) {

      // Iterate all tagsheader plugins and add a header for each plugin.
      $tags = $response->getCacheableMetadata()->getCacheTags();