Monday, May 16, 2016

HTTP 303 See Other - this was new to me

I've always used a redirect after user submits data, because it makes more sense to me to have user be looking at something he/she http-got, so the page can be refreshed without a confusing "re-send data" dialog by the web browser and without unnecessary data re-submission potentially resulting a data add/overwrite.
I've been doing it with HTTP 301 redirect, apparently there is something that makes more sense
HTTP 303 See Other

According to RFC 7231, which obsoletes RFC 2616, "A 303 response to a GET request indicates that the origin server does not have a representation of the target resource that can be transferred by the server over HTTP. However, the Location field value refers to a resource that is descriptive of the target resource, such that making a retrieval request on that other resource might result in a representation that is useful to recipients without implying that it represents the original target resource."

This was new to me in May 2016, he he. In the world where many websites don't even do form-submit any more, all Ajax and such. But many people believe HTTP 303 makes sense for REST API responses:

https://adayinthelifeof.nl/2012/05/02/301-vs-303/

During this presentation (and blog-post), I’m using a 303 HTTP status code to indicate that the operation has been completed and that the created resource can be found at another URI.