Skip to content

Commit

Permalink
Remove the Contao-Merge-Cache-Control header in the master request (see
Browse files Browse the repository at this point in the history
#2122)

Description
-----------

| Q                | A
| -----------------| ---
| Fixed issues     | Fixes #1959
| Docs PR or issue | -

Commits
-------

c02be77 Remove the Contao-Merge-Cache-Control header in the master request
  • Loading branch information
leofeyer committed Aug 7, 2020
1 parent 1f0a07d commit 4b882d8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public function onKernelResponse(ResponseEvent $event): void

if ($isMasterRequest) {
$this->currentStrategy = array_pop($this->strategyStack);
$response->headers->remove(self::MERGE_CACHE_HEADER);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public function testMergesCacheControlHeader(): void

$this->assertSame(30, $mainResponse->getMaxAge());
$this->assertSame('max-age=30, public', $mainResponse->headers->get('Cache-Control'));
$this->assertFalse($mainResponse->headers->has(SubrequestCacheSubscriber::MERGE_CACHE_HEADER));
}

public function testMakeMasterResponsePrivateIfSubrequestIsPrivate(): void
Expand All @@ -79,6 +80,7 @@ public function testMakeMasterResponsePrivateIfSubrequestIsPrivate(): void
$this->onKernelResponse($subscriber, $mainResponse, KernelInterface::MASTER_REQUEST);

$this->assertSame('private', $mainResponse->headers->get('Cache-Control'));
$this->assertFalse($mainResponse->headers->has(SubrequestCacheSubscriber::MERGE_CACHE_HEADER));
}

public function testIgnoresSubrequestWithoutMergeHeader(): void
Expand All @@ -100,6 +102,7 @@ public function testIgnoresSubrequestWithoutMergeHeader(): void
$this->onKernelResponse($subscriber, $mainResponse, KernelInterface::MASTER_REQUEST);

$this->assertSame('max-age=60, public', $mainResponse->headers->get('Cache-Control'));
$this->assertFalse($mainResponse->headers->has(SubrequestCacheSubscriber::MERGE_CACHE_HEADER));
}

public function testIgnoresSubrequestWithoutCacheControlHeader(): void
Expand All @@ -122,6 +125,7 @@ public function testIgnoresSubrequestWithoutCacheControlHeader(): void
$this->onKernelResponse($subscriber, $mainResponse, KernelInterface::MASTER_REQUEST);

$this->assertSame('max-age=60, public', $mainResponse->headers->get('Cache-Control'));
$this->assertFalse($mainResponse->headers->has(SubrequestCacheSubscriber::MERGE_CACHE_HEADER));
}

private function onKernelRequest(SubrequestCacheSubscriber $subscriber, int $requestType): void
Expand Down

0 comments on commit 4b882d8

Please sign in to comment.