Skip to content

Commit

Permalink
CS
Browse files Browse the repository at this point in the history
  • Loading branch information
aschempp committed Jun 20, 2018
1 parent 195ebda commit b594310
Showing 1 changed file with 6 additions and 10 deletions.
Expand Up @@ -30,15 +30,13 @@ class ResponseCacheStrategy implements ResponseCacheStrategyInterface
{
/**
* Cache-Control headers that are sent to the final response if they appear in ANY of the responses.
* @var array
*/
private static $overrideDirectives = ['no-cache', 'no-store', 'no-transform', 'must-revalidate', 'proxy-revalidate'];
private static $overrideDirectives = array('no-cache', 'no-store', 'no-transform', 'must-revalidate', 'proxy-revalidate');

/**
* Cache-Control headers that are sent to the final response if the appear in ALL of the responses.
* @var array
*/
private static $inheritDirectives = ['public', 'private', 'immutable'];
private static $inheritDirectives = array('public', 'private', 'immutable');

private $embeddedResponses = 0;
private $isNotCacheableResponseEmbedded = false;
Expand Down Expand Up @@ -90,8 +88,8 @@ public function add(Response $response)
$this->storeRelativeAgeDirective('s-maxage', $response->headers->getCacheControlDirective('s-maxage'), $age);

$expires = $response->getExpires();
$expires = null === $expires ? null : $expires->format('U') - $response->getDate()->format('U');
$this->storeRelativeAgeDirective('expires', $expires < 0 ? null : $expires, 0);
$expires = null !== $expires ? $expires->format('U') - $response->getDate()->format('U') : null;
$this->storeRelativeAgeDirective('expires', $expires >= 0 ? $expires : null, 0);
}

/**
Expand Down Expand Up @@ -146,8 +144,6 @@ public function update(Response $response)
*
* @see https://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html#sec13.4
*
* @param Response $response
*
* @return bool
*/
private function isUncacheable(Response $response)
Expand All @@ -165,7 +161,7 @@ private function isUncacheable(Response $response)
// A response received with any other status code (e.g. status codes 302 and 307)
// MUST NOT be returned in a reply to a subsequent request unless there are
// cache-control directives or another header(s) that explicitly allow it.
$cacheControl = ['max-age', 's-maxage', 'must-revalidate', 'proxy-revalidate', 'public', 'private', 'must-revalidate'];
$cacheControl = array('max-age', 's-maxage', 'must-revalidate', 'proxy-revalidate', 'public', 'private', 'must-revalidate');
foreach ($cacheControl as $key) {
if ($response->headers->hasCacheControlDirective($key)) {
return false;
Expand Down Expand Up @@ -194,7 +190,7 @@ private function storeRelativeAgeDirective($cacheKey, $value, $age)

if (false !== $this->ageDirectives[$cacheKey]) {
$value = $value - $age;
$this->ageDirectives[$cacheKey] = null === $this->ageDirectives[$cacheKey] ? $value : min($this->ageDirectives[$cacheKey], $value);
$this->ageDirectives[$cacheKey] = null !== $this->ageDirectives[$cacheKey] ? min($this->ageDirectives[$cacheKey], $value) : $value;
}
}
}

0 comments on commit b594310

Please sign in to comment.