PUT vs PATCH, and what does idempotent mean?
Practice this questionWANT TO UNDERSTAND THE CONCEPT FIRST?Learn PUT vs PATCH, and what does idempotent mean?
Definition:
PUT is defined around creating or replacing the state of a target resource, while PATCH applies a described partial change. Idempotency means repeating an identical operation has the same intended server-side effect as doing it once. It does not require every repeated response to contain the same status or body.
Key points:
-
PUT replaces the target representation; PATCH applies a partial change.
-
Idempotent means repeating the same request has the same intended effect.
-
PUT and DELETE are idempotent by semantics; PATCH depends on the operation.
-
“Set quantity to 3” can be idempotent; “increase quantity by 3” generally is not without a deduplication mechanism.
Example:
PUT /profiles/42with the same profile representation leaves the same intended state after repetition.PATCH /counters/42with “increment by 1” changes the state again on each attempt unless an idempotency key is enforced.- A repeated request can have a different response while still being idempotent.
Interview point:
- A repeated DELETE can return 404 after an initial success while remaining idempotent because the resource stays deleted.
Adapted from 02_NODE_EXPRESS_HTTP.md · “PUT vs PATCH, and what does idempotent mean?”. Code examples are study fragments. Difficulty and core labels are editorial estimates; version-specific behavior should be checked against your project.