Junior — Middle
What HTTP requests can be repeated without changing the server state?
sobes.tech AI
Answer from AI
HTTP requests that can be repeated without changing the server's state are called idempotent or safe. These include:
- GET — used to retrieve data, does not change the state.
- HEAD — similar to GET but without a response body.
- OPTIONS — requests supported methods.
- TRACE — returns diagnostic information.
Requests that are idempotent but can change the state include:
- PUT — updates a resource, repeated execution results in the same outcome.
- DELETE — deletes a resource, repeated execution will not change the result after the first deletion.
Unlike them, POST is usually not idempotent, as it creates new resources or changes the server's state with each call.