4 ms·
GET requests should have no side effects. In other words NOOP is idempotent
by dewiz 8y ago
GET requests should have no side effects. In other words NOOP is idempotent
- rusk 8y agoI'd just like to clarify that what you have described here is "safe" rather than "idempotent" [0]. Easy mistake to make, made the same mistake myself, idempotently (that is to say you only make it once ;) Get, and NOOP, are both "safe" and naturally "idempotent" since the former encompasses the latter. [0] https://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html https://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html
- thomasz 8y agoGET must be safe and idempodent. In the context of http, idempodency basically means that you get the same result for each request with the same url and the same set of parameters. Toggle should be implemented as post, since it’s neither safe, nor idempodent.
- rusk 8y agoyes
- mpweiher 8y ago> get the same result for each request with the same url and the same set of parameters. I think the resource can change externally...so it means that your GET request doesn't change it, but it doesn't have to be the same result every time.
- dalore 8y agoNo not the same result. How would the front page of any news site work then?
- thomasz 8y agoIIRC, the rfc uses “safe” instead of “side effect free”, which is very similar, but not exactly the same.
- deleted 8y ago[deleted]
- bad_user 8y agoReading from a database isn’t “side effect free”, neither is reading from a mutable variable. Given that HTTP requests are supposed to trigger database reads that may return a different result after some time, then “side effect free” would indeed be incorrect. The litmus test is ... does it always return the same output given the same input? If that can change, the it’s not describing a pure function, but a side effectful one. And the output of a GET request can and does change. Speaking of which people here aren’t talking of idempotency in a mathematical sense: f(f(x)) == f(x) If you really think about it, GET requests aren’t even idempotent ;-)
- icebraining 8y agoHaving no side-effects means it doesn't cause side-effects, not that it can't be "victim" to them. It's no the same as purity.
- deleted 8y ago[deleted]
- jimktrains2 8y agoGet should be safe, but that's not the same as indempotent. Delete requests are also indempotent as the final state will always be the same.