A key feature of HTTP is the support for conditional requests. This
allows the user agent to check the freshness of a cached
representation or to prevent update of a resource based on a stale
local representation. Liberator provides the client with the necessary
information and informs the client if the representation was not
To enable the conditional request based on the time of the last
modification, a resource must provide a function at the key
:last-modified. The value returned by this function will be
picked up by the default implementation of the decision function
:modified-since? and used to check against the request header
Curl shows that the the resource sends a 304 if the time stamp in the
request header relates to a fresh representation.
Liberator will handle If-Unmodified-Since as well and supports
conditional updates for PUT and POST.
While If-Modified-Since requires that the clocks of client and server
are sufficiently in sync, there is no such need for conditional
requests based on ETags. A resource can generate an ETag by providing
a function at the key :etag and the required outcome will be
calculated by liberator as expected.
Liberator does not support weak ETags.
The value generated by :etag will be considered a strong ETag.
Curl shows that the resource works as expected:
Liberator also supports the lesser known semantic of using * for
If-Match and If-None-Match. These are useful for
conditional updates of resources.