What is Idempotency in HTTP methods?

What is Idempotency in HTTP methods ?
Share this:

There is a set of HTTP methods defined by HTTP which is used to perform the desired action. They are also referred to as HTTP verbs. Different methods implement different semantics.

List of HTTP methods: 

  • GET
  • HEAD
  • POST
  • PUT

Idempotence :

Idempotence is the property where the operation can be applied multiple times without changing the result from the first application. In other words, the result or effect of the action/operation on the server for the first time is the same as the result of applying that same operation multiple times. Idempotency is concerned with the effect on the server not the response to the client.

DELETE method can be illustrated for this. Consider, you called the DELETE method to request the deletion of certain resources from the server. If the operation is successful i.e resource gets deleted, the server responds with status 200 (OK) or 204 ( No Content ). Now when you call that DELETE action again, there will be response status code 404 implying that resource to be deleted is not available. Here, the response is different in first and second time but the effect on the server is the same on calling DELETE action for a single time and second time. If you call this method for more time, there will be no effect on the server and the response is the same as the second time. Hence DELETE is an idempotent HTTP method.

All of the HTTP methods enlisted above are idempotent methods except for CONNECT and POST. 

While the PATCH request method is analogous to Update in CRUD. PATCH is not necessarily idempotent though it can be.

Happy Learning, !!!!! Have a great time ahead.

Take care and stay healthy and creative.


Related posts

Leave a Reply