[CalDAV/CardDAV] Avoid GET after PUT when the server didn't modify the component
evolution#28 (moved) describes the HTTP communication when a new iCalendar object is uploaded over CalDav:
- the client sends PUT and receives 201 Created with an ETag, then
- the client sends GET to retrieve the stored resource.
My reading of RFC8144 and RFC7240 is, that if on the PUT a "Prefer: return=minimal" is inserted, and the server returns Content-Length: 0 + ETag, then the server has not modifed the uploaded resource and the client does not need to call the final GET to retrieve it.
In fact, even without 'Prefer: return=minimal` https://tools.ietf.org/html/rfc7231#page-27 says:
An origin server MUST NOT send a validator header field (Section 7.2), such as an ETag or Last-Modified field, in a successful response to PUT unless the request's representation data was saved without any transformation applied to the body (i.e., the resource's new representation data is identical to the representation data received in the PUT request) and the validator field value reflects the new representation.
So I propose this approach:
- send PUT with Prefer: representation-minimal
- if the response has ETag and Content-Length: 0, then assume the server has not modified the uploaded data, no GET afterards i necessary
- if the response has ETag and content, then use them and skip the subsequent GET.