Skip to content

Commit

Permalink
Never us shared max age if CustomTtlListener is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-schranz authored Jul 22, 2024
1 parent cc511e5 commit 7ec0774
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/SymfonyCache/CustomTtlListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,16 @@ public function __construct($ttlHeader = 'X-Reverse-Proxy-TTL', $keepTtlHeader =
public function useCustomTtl(CacheEvent $e)
{
$response = $e->getResponse();
if (!$response->headers->has($this->ttlHeader)) {
return;
}
$backup = $response->headers->hasCacheControlDirective('s-maxage')
? $response->headers->getCacheControlDirective('s-maxage')
: 'false'
;
$response->headers->set(static::SMAXAGE_BACKUP, $backup);
$response->setTtl($response->headers->get($this->ttlHeader));
$response->setTtl(
$response->headers->has($this->ttlHeader)
? $response->headers->get($this->ttlHeader)
: 0
);
}

/**
Expand Down

0 comments on commit 7ec0774

Please sign in to comment.