handleCache

Processes header tags in a request and writes responses given on requested cache status.

@safe
bool
handleCache
(,,,,
string cache_control = null
,
Duration max_age = Duration.zero
)

Parameters

req HTTPServerRequest

the client request used to determine cache control flow.

res HTTPServerResponse

the response to write cache headers to.

etag ETag

if set to anything except .init, adds a Etag header to the response and enables handling of If-Match and If-None-Match cache control request headers.

last_modified SysTime

if set to anything except .init, adds a Last-Modified header to the response and enables handling of If-Modified-Since and If-Unmodified-Since cache control request headers.

cache_control string

if set, adds or modifies the Cache-Control header in the response to this string. Might get an additional max-age value appended if max_age is set.

max_age Duration

optional duration to set the Expires header and Cache-Control max-age part to. (if no existing max-age= part is given in the cache_control parameter)

Return Value

Type: bool

true if the cache was already handled and no further response must be sent or false if a response must be sent.

Meta