Checks whether a response has not been modified according to the 'If-None-Match'
(Etags) and 'If-Modified-Since' (last modification date) request headers
headers. If the response is detected to be not modified, it is marked as so
accordingly so the client can be informed of that.

Sets the response Etag, Etags are a strong indicative that a response can be
cached by a HTTP client. A bad way of generating Etags is creating a hash of the
response output, instead generate a unique hash of the unique components that
identifies a request, such as a modification time, a resource Id, and anything
else you consider it makes it unique.

Sets the Cache-Control max-age directive. The max-age is the number of seconds
after which the response should no longer be considered a good candidate to be
fetched from the local (client) cache. If called with no parameters, this
function will return the current max-age value if any

Sets the Cache-Control must-revalidate directive. must-revalidate indicates that
the response should not be served stale by a cache under any circumstance
without first revalidating with the origin. If called with no parameters, this
function will return whether must-revalidate is present.

Sets the Cache-Control s-maxage directive. The max-age is the number of seconds
after which the response should no longer be considered a good candidate to be
fetched from a shared cache (like in a proxy server). If called with no
parameters, this function will return the current max-age value if any

Sets the response content type. It can be either a file extension which will be
mapped internally to a mime-type or a string representing a mime-type if
$contentType is null the current content type is returned if $contentType is an
associative array, content type definitions will be stored/replaced

Sets the Vary header for the response, if an array is passed, values will be
imploded into a comma separated string. If no parameters are passed, then an
array with the current Vary header value is returned

Method Detail

Parameters

array
$optionsoptionalarray()

list of parameters to setup the response. Possible values are: - body: the
response text that should be sent to the client - status: the HTTP status code
to respond with - type: a complete mime-type string or an extension mapped in
this class - charset: the charset for the response body

Parameters

Returns

Checks whether a response has not been modified according to the
'If-None-Match' (Etags) and 'If-Modified-Since' (last modification date) request
headers headers. If the response is detected to be not modified, it is marked as
so accordingly so the client can be informed of that.

In order to mark a response as not modified, you need to set at least the
Last-Modified etag response header before calling this method. Otherwise a
comparison will not be possible.

Returns

This method acts as a setter/getter depending on the type of the argument. If
the method is called with no arguments, it returns all configurations.

If the method is called with a string as argument, it returns either the
given configuration if it is set, or null, if it's not set.

If the method is called with an array as argument, it will set the cookie
configuration to the cookie container.

Parameters

array
$optionsoptionalnull

Either null to get all cookies, string for a specific cookie or array to set
cookie. ### Options (when setting a configuration) - name: The Cookie name -
value: Value of the cookie - expire: Time the cookie expires in - path: Path the
cookie applies to - domain: Domain the cookie is for. - secure: Is the cookie
https? - httpOnly: Is the cookie available in the client? ## Examples ###
Getting all cookies <code>$this-&gt;cookie()</code> ### Getting a certain cookie
configuration <code>$this-&gt;cookie('MyCookie')</code> ### Setting a cookie
configuration <code>$this-&gt;cookie((array) $options)</code>

Parameters

Sets the response Etag, Etags are a strong indicative that a response can be
cached by a HTTP client. A bad way of generating Etags is creating a hash of the
response output, instead generate a unique hash of the unique components that
identifies a request, such as a modification time, a resource Id, and anything
else you consider it makes it unique.

Second parameter is used to instruct clients that the content has changed,
but sematicallly, it can be used as the same thing. Think for instance of a page
with a hit counter, two different page views are equivalent, but they differ by
a few bytes. This leaves off to the Client the decision of using or not the
cached page.

If no parameters are passed, current Etag header is returned.

Parameters

string
$tagoptionalnull

$hash the unique has that identifies this response

boolean
$weakoptionalfalse

whether the response is semantically the same as other with the same hash or not

Returns

Sets the Expires header for the response by taking an expiration time If
called with no parameters it will return the current Expires value

Examples:

$response->expires('now') Will Expire the response cache now
$response->expires(new DateTime('+1 day')) Will set the
expiration in next 24 hours $response->expires() Will return the
current expiration header value

String header

Array of string headers

Multiple calls for setting the same header name will have the same effect as
setting the header once with the last value sent for it e.g
header('WWW-Authenticate: Negotiate'); header('WWW-Authenticate:
Not-Negotiate'); will have the same effect as only doing
header('WWW-Authenticate: Not-Negotiate');

Parameters

string|array
$headeroptionalnull

$header. An array of header strings or a single header string - an associative
array of "header name" =&gt; "header value" is also accepted - an array of
string headers is also accepted

string
$valueoptionalnull

$value. The header value.

Returns

Parameters

integer|array
$codeoptionalnull

If $code is an integer, then the corresponding code/message is returned if it
exists, null if it does not exist. If $code is an array, then the 'code' and
'message' keys of each nested array are added to the default HTTP codes.
Example: httpCodes(404); // returns array(404 =&gt; 'Not Found')
httpCodes(array( 701 =&gt; 'Unicorn Moved', 800 =&gt; 'Unexpected Minotaur' ));
// sets these new values, and returns true

Returns

mixedassociative array of the HTTP codes as keys, and the message strings as values,
or null of the given $code does not exist.

Parameters

Returns

Sets the Cache-Control max-age directive. The max-age is the number of
seconds after which the response should no longer be considered a good candidate
to be fetched from the local (client) cache. If called with no parameters, this
function will return the current max-age value if any

Parameters

integer
$secondsoptionalnull

if null, the method will return the current max-age value

Returns

Sets the Last-Modified header for the response by taking an modification time
If called with no parameters it will return the current Last-Modified value

Examples:

$response->modified('now') Will set the Last-Modified to the
current time $response->modified(new DateTime('+1 day')) Will
set the modification date in the past 24 hours
$response->modified() Will return the current Last-Modified
header value

Parameters

string|DateTime
$timeoptionalnull

Returns

Sets the Cache-Control must-revalidate directive. must-revalidate indicates
that the response should not be served stale by a cache under any circumstance
without first revalidating with the origin. If called with no parameters, this
function will return whether must-revalidate is present.

Parameters

integer
$enableoptionalnull

$seconds if null, the method will return the current must-revalidate value

Returns

Sets the Cache-Control s-maxage directive. The max-age is the number of
seconds after which the response should no longer be considered a good candidate
to be fetched from a shared cache (like in a proxy server). If called with no
parameters, this function will return the current max-age value if any

Parameters

Returns

Throws

Sets the response content type. It can be either a file extension which will
be mapped internally to a mime-type or a string representing a mime-type if
$contentType is null the current content type is returned if $contentType is an
associative array, content type definitions will be stored/replaced

Replacing a content type definition

Parameters

Returns

Sets the Vary header for the response, if an array is passed, values will be
imploded into a comma separated string. If no parameters are passed, then an
array with the current Vary header value is returned