Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ public function __invoke(string $key): bool
}

$hasPublicOrPrivateCacheControlDirective = $hasCacheControlDirective('public') || $hasCacheControlDirective('private');
$hasNoStoreCacheControlDirective = $hasCacheControlDirective('no-store');

foreach ($attributes as $cache) {
if (true === $cache->public && !$hasPublicOrPrivateCacheControlDirective) {
Expand All @@ -184,7 +185,7 @@ public function __invoke(string $key): bool
$response->headers->addCacheControlDirective('no-store');
}

if (false === $cache->noStore) {
if (false === $cache->noStore && !$hasNoStoreCacheControlDirective) {
$response->headers->removeCacheControlDirective('no-store');
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,17 @@ public function testAttributeRespectsExplicitPublicFromController()
$this->assertFalse($response->headers->hasCacheControlDirective('private'));
}

public function testAttributeNoStoreDoesNotRemoveExplicitNoStore()
{
$request = $this->createRequest(new Cache(noStore: false));
$response = new Response();
$response->headers->addCacheControlDirective('no-store');

$this->listener->onKernelResponse($this->createEventMock($request, $response));

$this->assertTrue($response->headers->hasCacheControlDirective('no-store'));
}

public static function provideVaryHeaderScenarios(): \Traversable
{
yield 'no vary headers at all' => [
Expand Down
Loading