Cache
in package
Leaf Http Caching ------------------------------------ HTTP Caching made simple with Leaf
Tags
Table of Contents
Methods
- etag() : mixed
- Set ETag HTTP Response Header
- expires() : mixed
- Set Expires HTTP response header
- lastModified() : mixed
- Set Last-Modified HTTP Response Header
Methods
etag()
Set ETag HTTP Response Header
public
static etag(string $value[, string $type = "strong" ]) : mixed
Set the etag header and stop if the conditional GET request matches.
The value
argument is a unique identifier for the current resource.
The type
argument indicates whether the etag should be used as a strong or
weak cache validator.
When the current request includes an 'If-None-Match' header with a matching etag, execution is immediately stopped. If the request method is GET or HEAD, a '304 Not Modified' response is sent.
Parameters
- $value : string
-
The etag value
- $type : string = "strong"
-
The type of etag to create; either "strong" or "weak"
expires()
Set Expires HTTP response header
public
static expires(string|int $time) : mixed
The Expires
header tells the HTTP client the time at which
the current resource should be considered stale. At that time the HTTP
client will send a conditional GET request to the server; the server
may return a 200 OK if the resource has changed, else a 304 Not Modified
if the resource has not changed. The Expires
header should be used in
conjunction with the etag()
or lastModified()
methods above.
Parameters
- $time : string|int
-
If string, a time to be parsed by
strtotime()
; If int, a UNIX timestamp;
lastModified()
Set Last-Modified HTTP Response Header
public
static lastModified(int $time) : mixed
Set the HTTP 'Last-Modified' header and stop if a conditional
GET request's If-Modified-Since
header matches the last modified time
of the resource. The time
argument is a UNIX timestamp integer value.
When the current request includes an 'If-Modified-Since' header that
matches the specified last modified time, the application will stop
and send a '304 Not Modified' response to the client.
Parameters
- $time : int
-
The last modified UNIX timestamp