Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. ResponseCacheStrategy.php

function ResponseCacheStrategy::storeRelativeAgeDirective

Store lowest max-age/s-maxage/expires for the final response.

The response might have been stored in cache a while ago. To keep things comparable, we have to subtract the age so that the value is normalized for an age of 0.

If the value is lower than the currently stored value, we update the value, to keep a rolling minimal value of each instruction. If the value is NULL, the directive will not be set on the final response.

1 call to ResponseCacheStrategy::storeRelativeAgeDirective()
ResponseCacheStrategy::add in vendor/symfony/http-kernel/HttpCache/ResponseCacheStrategy.php
Adds a Response.

File

vendor/symfony/http-kernel/HttpCache/ResponseCacheStrategy.php, line 218

Class

ResponseCacheStrategy
ResponseCacheStrategy knows how to compute the Response cache HTTP header based on the different response cache headers.

Namespace

Symfony\Component\HttpKernel\HttpCache

Code

private function storeRelativeAgeDirective(string $directive, ?int $value, ?int $expires, int $age) : void {
    if (null === $value && null === $expires) {
        $this->ageDirectives[$directive] = false;
    }
    if (false !== $this->ageDirectives[$directive]) {
        $value = min($value ?? PHP_INT_MAX, $expires ?? PHP_INT_MAX);
        $value -= $age;
        $this->ageDirectives[$directive] = null !== $this->ageDirectives[$directive] ? min($this->ageDirectives[$directive], $value) : $value;
    }
}
RSS feed
Powered by Drupal