class DefaultRequestPolicy extends ChainRequestPolicy (View source)

The default page cache request policy.

Delivery of cached pages is denied if either the application is running from the command line or the request was not initiated with a safe method (GET or HEAD). Also caching is only allowed for requests without a session cookie.

Properties

protected RequestPolicyInterface[] $rules

A list of policy rules to apply when this policy is evaluated.

from  ChainRequestPolicy

Methods

string|null
check(Request $request)

Determines whether delivery of a cached page should be attempted.

$this
addPolicy(RequestPolicyInterface $policy)

Add a policy to the list of policy rules.

__construct(SessionConfigurationInterface $session_configuration)

Constructs the default page cache request policy.

Details

string|null check(Request $request)

Determines whether delivery of a cached page should be attempted.

Note that the request-policy check runs very early. In particular it is not possible to determine the logged in user. Also the current route match is not yet present when the check runs. Therefore, request-policy checks need to be designed in a way such that they do not depend on any other service and only take in account the information present on the incoming request.

When matching against the request path, special attention is needed to support path prefixes which are often used on multilingual sites.

Parameters

Request $request

The incoming request object.

Return Value

string|null

One of static::ALLOW, static::DENY or NULL. Calling code may attempt to deliver a cached page if static::ALLOW is returned. Returns NULL if the policy is not specified for the given request.

$this addPolicy(RequestPolicyInterface $policy)

Add a policy to the list of policy rules.

Parameters

RequestPolicyInterface $policy

The request policy rule to add.

Return Value

$this

__construct(SessionConfigurationInterface $session_configuration)

Constructs the default page cache request policy.

Parameters

SessionConfigurationInterface $session_configuration

The session configuration.