Should a POST request render HTML or redirect?
I hate it when your on a page and refresh and get the browser telling you, you're going to post data again.
Yes. It should send an entity or redirect!
(Sorry, the old programming jokes have to come out sometimes).
It really depends on whether you can meaningfully give something to GET, that makes sense standing on it's own.
Example: I buy something, I get a page saying "thank you, yadda yadda order number, receipt, yadda".
That should be a 303 See Other redirect, so that I GET a page with that info. I can bookmark it for later, refreshing just refreshes the GET. Happy days.
There are times though, when it only makes sense to render an immediate response, and if they refresh, then to repeat the actual operation, and bookmarking is meaningless That should not be a redirect.
For the most part, aim to have as few of the latter anyway. It is though most useful if you have to return them to the form because something failed - nobody wants a bookmark of a failed form, they want to fix what needs fixing and get on with it.
Note, many server-side systems (ASP etc) use 302 when you redirect from a POST, which strictly should mean that it POSTs again, but just about no browser does. Instead, be clearer:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With