Explain the concept of 'idempotency.' Which HTTP methods are idempotent, and why does it matter for a distributed system?
Last updated
Idempotency means repeating an operation leaves the same final state as doing it once (responses may differ, e.g. a second
DELETEreturns 404).Idempotent:
GET,HEAD,OPTIONS,PUT,DELETE. Not idempotent:POSTand generallyPATCH.In unreliable networks a lost response leaves clients unsure, so idempotent calls can be retried safely. Non-idempotent ones need protection like an idempotency key.
- https://developer.mozilla.org/en-US/docs/Glossary/Idempotent
- https://www.geeksforgeeks.org/javascript/what-is-an-idempotent-rest-api/
- https://stackoverflow.com/questions/66249638/how-to-handle-put-endpoint-with-immutable-resource
- https://www.geeksforgeeks.org/java/what-is-the-difference-between-put-post-and-patch-in-restful-api/
- https://www.geeksforgeeks.org/html/full-stack-developer-interview-questions-and-answers/
- https://www.geeksforgeeks.org/interview-experiences/sp-global-qa-interview-experience/
- https://stackoverflow.com/questions/tagged/http-put?tab=Newest
- https://developer.mozilla.org/en-US/docs/Glossary/Safe/HTTP