← Lessons

quiz vs the machine

Gold1300

Networking

Idempotent and Safe HTTP Methods

Properties that make retries and caching reliable.

4 min read · core · beat Gold to climb

Two important properties

HTTP methods carry semantic promises. A method is safe if it is only meant to read, never changing server state. A method is idempotent if making the same request many times has the same effect as making it once.

How the methods classify

  • GET and HEAD are safe and idempotent, pure reads.
  • PUT is idempotent because it sets a resource to a value, so repeating it leaves the same result.
  • DELETE is idempotent, since deleting twice still leaves the resource gone.
  • POST is neither safe nor idempotent, because it often creates a new resource each time.

These properties matter for reliability. A client or proxy can safely retry an idempotent request after a timeout without fear of duplicate side effects, which is why network libraries retry GET and PUT but hesitate on POST. Safe methods can be prefetched and cached freely. When a non idempotent operation must be retried safely, designers add an idempotency key so the server recognizes and ignores duplicates.

Key idea

Safe methods only read and idempotent methods repeat harmlessly, which makes retries and caching reliable.

Check yourself

Answer to earn rating on the learn ladder.

1. What does idempotent mean for an HTTP method?

2. Why do libraries hesitate to retry POST automatically?