PHP Класс Bluz\Http\CacheControl

Wrapper for working with HTTP headers - Cache-Control - Last-Modified - Expires - ETag - Age
Наследование: use trait Bluz\Common\Container\Container
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$response instance

Открытые методы

Метод Описание
__construct ( Response $response ) Create instance
expire ( ) : void Marks the response stale by setting the Age header to be equal to the maximum age of the response
getAge ( ) : integer Returns the age of the response
getEtag ( ) : string Returns the literal value of the ETag HTTP header
getExpires ( ) : string Returns the value of the Expires header as a DateTime instance
getLastModified ( ) : string Returns the Last-Modified HTTP header as a string
getMaxAge ( ) : integer Returns the number of seconds after the time specified in the response's Date header when the response should no longer be considered fresh.
getTtl ( ) : integer | null Returns the response's time-to-live in seconds.
setAge ( integer $age ) : void Set the age of the response
setClientTtl ( integer $seconds ) : void Sets the response's time-to-live for private/client caches.
setEtag ( string $etag, boolean $weak = false ) : void Sets the ETag value
setExpires ( DateTime | string $date ) : void Sets the Expires HTTP header with a DateTime instance
setLastModified ( DateTime | string $date ) : void Sets the Last-Modified HTTP header with a DateTime instance or string
setMaxAge ( integer $value ) : void Sets the number of seconds after which the response should no longer be considered fresh.
setPrivate ( ) : void Marks the response as "private".
setPublic ( ) : void Marks the response as "public".
setSharedMaxAge ( integer $value ) : void Sets the number of seconds after which the response should no longer be considered fresh by shared caches.
setTtl ( integer $seconds ) : void Sets the response's time-to-live for shared caches.

Защищенные методы

Метод Описание
updateCacheControlHeader ( ) : string Prepare Cache-Control header

Описание методов

__construct() публичный Метод

Create instance
public __construct ( Response $response )
$response Bluz\Response\Response

expire() публичный Метод

Marks the response stale by setting the Age header to be equal to the maximum age of the response
public expire ( ) : void
Результат void

getAge() публичный Метод

Returns the age of the response
public getAge ( ) : integer
Результат integer The age of the response in seconds

getEtag() публичный Метод

Returns the literal value of the ETag HTTP header
public getEtag ( ) : string
Результат string The ETag HTTP header or null if it does not exist

getExpires() публичный Метод

Returns the value of the Expires header as a DateTime instance
public getExpires ( ) : string
Результат string A string or null if the header does not exist

getLastModified() публичный Метод

Returns the Last-Modified HTTP header as a string
public getLastModified ( ) : string
Результат string A string or null if the header does not exist

getMaxAge() публичный Метод

First, it checks for a s-maxage directive, then a max-age directive, and then it falls back on an expires header. It returns null when no maximum age can be established.
public getMaxAge ( ) : integer
Результат integer Number of seconds

getTtl() публичный Метод

It returns null when no freshness information is present in the response. When the responses TTL is <= 0, the response may not be served from cache without first revalidating with the origin.
public getTtl ( ) : integer | null
Результат integer | null The TTL in seconds

setAge() публичный Метод

Set the age of the response
public setAge ( integer $age ) : void
$age integer
Результат void

setClientTtl() публичный Метод

This method adjusts the Cache-Control/max-age directive.
public setClientTtl ( integer $seconds ) : void
$seconds integer Number of seconds
Результат void

setEtag() публичный Метод

Sets the ETag value
public setEtag ( string $etag, boolean $weak = false ) : void
$etag string The ETag unique identifier
$weak boolean Whether you want a weak ETag or not
Результат void

setExpires() публичный Метод

Sets the Expires HTTP header with a DateTime instance
public setExpires ( DateTime | string $date ) : void
$date DateTime | string A \DateTime instance or date as string
Результат void

setLastModified() публичный Метод

Sets the Last-Modified HTTP header with a DateTime instance or string
public setLastModified ( DateTime | string $date ) : void
$date DateTime | string A \DateTime instance or date as string
Результат void

setMaxAge() публичный Метод

This methods sets the Cache-Control max-age directive.
public setMaxAge ( integer $value ) : void
$value integer Number of seconds
Результат void

setPrivate() публичный Метод

It makes the response ineligible for serving other clients.
public setPrivate ( ) : void
Результат void

setPublic() публичный Метод

It makes the response eligible for serving other clients.
public setPublic ( ) : void
Результат void

setSharedMaxAge() публичный Метод

This methods sets the Cache-Control s-maxage directive.
public setSharedMaxAge ( integer $value ) : void
$value integer Number of seconds
Результат void

setTtl() публичный Метод

This method adjusts the Cache-Control/s-maxage directive.
public setTtl ( integer $seconds ) : void
$seconds integer Number of seconds
Результат void

updateCacheControlHeader() защищенный Метод

Prepare Cache-Control header
protected updateCacheControlHeader ( ) : string
Результат string

Описание свойств

$response защищенное свойство

instance
protected $response