Monday, 9 September 2013

How can I make an idempotent POST cacheable on the basis of URL, Headers and Body?

How can I make an idempotent POST cacheable on the basis of URL, Headers
and Body?

Consider a web service that exposes a /search endpoint. Any operation on
that endpoint would be a good candidate for the GET method as it would be
idempotent. The complexity of the search parameters however may result in
extremely long URLs that may not be handled properly (despite the RFC not
specifying a hard limit) by the client, the proxies, or even the server.
So the only alternative would be to use POST and pass the search criteria
in the body of the request. It wouldn't be a big deal if it it wasn't for
the fact that the response is now not cacheable: it is not possible to
define it's cacheability on the basis of its URL, some of the headers
(Accept) and the full body (where the actual search criteria are).
Am I right in thinking that HTTP/1.1 is lacking in this respect and there
is no elegant and simple solution to the problem?
Thanks

No comments:

Post a Comment