class CacheHeadersCheck implements EnvironmentCheck (View source)

Check cache headers for any response, can specify directives that must be included and also must be excluded from Cache-Control headers in response. Also checks for existence of ETag.

Traits

Simple helper for env checks which require HTTP clients.

Properties

public Client $client

Client for making requests, set vi Injector.

from  Fetcher
protected string $url

Absolute URL for requests.

from  Fetcher
protected array $mustInclude

Settings that must be included in the Cache-Control header

protected array $mustExclude

Settings that must be excluded in the Cache-Control header

protected ValidationResult $result

Result to keep track of status and messages for all checks, reuses ValidationResult for convenience.

Methods

public
setURL(string $url)

Set URL for requests.

from  Fetcher
public
string
getURL()

Getter for URL

from  Fetcher
public
__construct(string $url = '', array $mustInclude = [], array $mustExclude = [])

Set up with URL, arrays of header settings to check.

public
array
check()

Check that correct caching headers are present.

Details

Fetcher setURL(string $url)

Set URL for requests.

Parameters

string $url

Relative URL

Return Value

Fetcher

string getURL()

Getter for URL

Return Value

string

__construct(string $url = '', array $mustInclude = [], array $mustExclude = [])

Set up with URL, arrays of header settings to check.

Parameters

string $url
array $mustInclude

Settings that must be included in Cache-Control

array $mustExclude

Settings that must be excluded in Cache-Control

array check()

Check that correct caching headers are present.

Return Value

array

Result with 'status' and 'message' keys.

Status is EnvironmentCheck::ERROR, EnvironmentCheck::WARNING, or EnvironmentCheck::OK.