vibe.d beta banner
get vibe.d

Asynchronous I/O that doesn’t get in your way, written in D

Function handleCache

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

bool handleCache (
  scope HTTPServerRequest req,
  scope HTTPServerResponse res,
  ETag etag,
  std.datetime.systime.SysTime last_modified,
  string cache_control = null,
  core.time.Duration max_age = zero()
) @safe;


req the client request used to determine cache control flow.
res the response to write cache headers to.
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 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 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 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)


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


Sönke Ludwig


© 2012-2015 Sönke Ludwig


Subject to the terms of the MIT license, as written in the included LICENSE.txt file.