class CacheControlDirectives (View source)

Cache-Control HTTP header generation/parsing

Properties

protected array $cacheDirectives

Methods

fromRawHeader(string $rawHeaderValue)

Internally sets the cache directives correctly by parsing the given Cache-Control header value.

void
setDirective(string $name, string|null $value = null)

Sets a special directive for use in the Cache-Control header, according to RFC 2616 / 14.9

void
removeDirective(string $name)

Removes a special directive previously set for the Cache-Control header.

mixed
getDirective(string $name)

Returns the value of the specified Cache-Control directive.

array
getDirectives()

No description

string|null
getCacheControlHeaderValue()

Renders and returns a Cache-Control header value, based on the previously set cache control directives.

Details

static CacheControlDirectives fromRawHeader(string $rawHeaderValue)

Internally sets the cache directives correctly by parsing the given Cache-Control header value.

Parameters

string $rawHeaderValue

The value of a specification compliant Cache-Control header

Return Value

CacheControlDirectives

void setDirective(string $name, string|null $value = null)

Sets a special directive for use in the Cache-Control header, according to RFC 2616 / 14.9

Parameters

string $name

Name of the directive, for example "max-age"

string|null $value

An optional value

Return Value

void

void removeDirective(string $name)

Removes a special directive previously set for the Cache-Control header.

Parameters

string $name

Name of the directive, for example "public"

Return Value

void

mixed getDirective(string $name)

Returns the value of the specified Cache-Control directive.

If the cache directive is not present, NULL is returned. If the specified directive is present but contains no value, this method returns true. Finally, if the directive is present and does contain a value, the value is returned.

Parameters

string $name

Name of the cache directive, for example "max-age"

Return Value

mixed

array getDirectives()

No description

Return Value

array

string|null getCacheControlHeaderValue()

Renders and returns a Cache-Control header value, based on the previously set cache control directives.

Return Value

string|null

Either the value of the header or NULL if it shall be omitted