Documentation

ResponseCacheStrategy
in package
implements ResponseCacheStrategyInterface

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

This implementation changes the main response TTL to the smallest TTL received or force validation if one of the surrogates has validation cache strategy.

Tags
author

Fabien Potencier fabien@symfony.com

Interfaces, Classes and Traits

ResponseCacheStrategyInterface
ResponseCacheStrategyInterface implementations know how to compute the Response cache HTTP header based on the different response cache headers.

Table of Contents

INHERIT_DIRECTIVES  = ['public', 'immutable']
Cache-Control headers that are sent to the final response if they appear in ALL of the responses.
OVERRIDE_DIRECTIVES  = ['private', 'no-cache', 'no-store', 'no-transform', 'must-revalidate', 'proxy-revalidate']
Cache-Control headers that are sent to the final response if they appear in ANY of the responses.
$age  : mixed
$ageDirectives  : mixed
$embeddedResponses  : mixed
$flagDirectives  : mixed
$isNotCacheableResponseEmbedded  : mixed
add()  : mixed
Adds a Response.
update()  : mixed
Updates the Response HTTP headers based on the embedded Responses.
storeRelativeAgeDirective()  : mixed
Store lowest max-age/s-maxage/expires for the final response.
willMakeFinalResponseUncacheable()  : bool
RFC2616, Section 13.4.

Constants

INHERIT_DIRECTIVES

Cache-Control headers that are sent to the final response if they appear in ALL of the responses.

private mixed INHERIT_DIRECTIVES = ['public', 'immutable']

OVERRIDE_DIRECTIVES

Cache-Control headers that are sent to the final response if they appear in ANY of the responses.

private mixed OVERRIDE_DIRECTIVES = ['private', 'no-cache', 'no-store', 'no-transform', 'must-revalidate', 'proxy-revalidate']

Properties

$ageDirectives

private mixed $ageDirectives = ['max-age' => null, 's-maxage' => null, 'expires' => null]

$flagDirectives

private mixed $flagDirectives = ['no-cache' => null, 'no-store' => null, 'no-transform' => null, 'must-revalidate' => null, 'proxy-revalidate' => null, 'public' => null, 'private' => null, 'immutable' => null]

Methods

update()

Updates the Response HTTP headers based on the embedded Responses.

public update(Response $response) : mixed
Parameters
$response : Response
Return values
mixed

storeRelativeAgeDirective()

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

private storeRelativeAgeDirective(string $directive, int|null $value, int $age, bool $isHeuristicallyCacheable) : mixed

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 and the isHeuristicallyCacheable parameter is false, the directive will not be set on the final response. In this case, not all responses had the directive set and no value can be found that satisfies the requirements of all responses. The directive will be dropped from the final response.

If the isHeuristicallyCacheable parameter is true, however, the current response has been marked as cacheable in a public (shared) cache, but did not provide an explicit lifetime that would serve as an upper bound. In this case, we can proceed and possibly keep the directive on the final response.

Parameters
$directive : string
$value : int|null
$age : int
$isHeuristicallyCacheable : bool
Return values
mixed

Search results