Understanding Idempotent HTTP Requests: Definitions and Classification
This article explains the concept of idempotent HTTP requests, defines idempotency, lists which HTTP methods are idempotent or not, and clarifies why methods like GET, HEAD, PUT, DELETE are safe to retry while POST, PATCH, and CONNECT are not.
When implementing retry mechanisms for client‑side HTTP requests, it is important to know which methods are considered idempotent. The library axios-retry retries by default only on network errors or 5xx responses for idempotent requests such as GET, HEAD, OPTIONS, PUT or DELETE.
An HTTP method is idempotent if a single request has the same effect on the server as multiple identical requests. In other words, repeating the request does not change the final state of the resource.
The article lists the classification of HTTP methods:
Safe (and idempotent) requests: GET, HEAD, OPTIONS, TRACE – these only read data and never modify server state.
Non‑idempotent requests: POST – typically creates a new resource each time it is called.
Idempotent requests: PUT – replaces a resource entirely; repeating the call leaves the resource unchanged after the first successful update.
Idempotent requests: DELETE – removes a resource; subsequent deletions have no further effect.
Conditional idempotency: PATCH – may be idempotent in some cases but generally is not, especially when it modifies auto‑incrementing fields.
Non‑idempotent request: CONNECT – establishes a tunnel; each call creates a new connection.
Example of a non‑idempotent POST request that creates a new row each time:
POST /add_row HTTP/1.1
POST /add_row HTTP/1.1 -> Adds a 2nd row
POST /add_row HTTP/1.1 -> Adds a 3rd rowIn summary, the idempotent HTTP methods are GET, HEAD, PUT, DELETE, OPTIONS, and TRACE, while POST, PATCH, and CONNECT are considered non‑idempotent.
Sohu Tech Products
A knowledge-sharing platform for Sohu's technology products. As a leading Chinese internet brand with media, video, search, and gaming services and over 700 million users, Sohu continuously drives tech innovation and practice. We’ll share practical insights and tech news here.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.