News for hackers. Stuff that matters.
Re:Ask HN: Why would anyone POST anything in AJAX? by cperciva on Saturday April 18, 2009 @06:25PM (#568816)
First off, the HTTP specification requires that GET (and HEAD) requests be idempotent to enable caching.

Technically, PUT request are supposed to be idempotent, while GET and HEAD are supposed to be side-effect free (which is strictly stronger than idempotency).

Re:Ask HN: Why would anyone POST anything in AJAX? by jon_dahl on Saturday April 18, 2009 @06:35PM (#568831)
PUT is supposed to be idempotent? So an "increment" or "reverse" request should technically be a POST?

Or does the idempoten-cy apply only to the response from the server, and not the state of the data on the server?

Re:Ask HN: Why would anyone POST anything in AJAX? by cperciva on Saturday April 18, 2009 @09:28PM (#568974)
PUT is supposed to be idempotent? So an "increment" or "reverse" request should technically be a POST?

Absolutely. User-agents are allowed to retry PUTs transparently -- it's only for POSTs that they're supposed to put up a "are you sure you want to re-submit this form? Bad stuff might happen" dialog.

Re:Ask HN: Why would anyone POST anything in AJAX? by pmjordan on Saturday April 18, 2009 @06:39PM (#568834)
That's certainly my understanding of it. PUT has semantics of resource creation or updating, like writing a file: whatever you upload replaces what is already there, if anything. You can process the data of course, but the outcome should depend only on the request data itself, not state.
Re:Ask HN: Why would anyone POST anything in AJAX? by pmjordan on Saturday April 18, 2009 @06:33PM (#568826)
Thanks for correcting the definition of idempotence in my brain! (edited original post)