Junior — Middle
Can the HTTP DELETE method be considered safe for repeated requests without changing the server state?
sobes.tech AI
Answer from AI
The DELETE HTTP method is considered idempotent, meaning that repeated requests with this method should lead to the same server state. However, it is not safe in the sense of having no effect on state — it changes the resource by deleting it.
If the first DELETE request deletes the resource, subsequent DELETE requests to the same resource should not change the state further (the resource is already deleted), but they may return, for example, a 404 or 204 No Content error.
In summary:
- DELETE is not safe because it modifies server state.
- DELETE is idempotent because repeated requests do not further change the state.
Therefore, DELETE cannot be considered safe, but it can be considered idempotent.