GET vs. POST: What's the difference?

The key difference between GET and POST HTTP methods is that GET only retrieves data from a server while POST can modify or update server-side resources. POSTs can also trigger server-side processing routines that don't update anything. The only restriction on POST operations is they cannot replicate PUT or PATCH behavior.

GET and POST were introduced with the HTTP 1.0 specification in 1996.

What does the GET method do?

The HTTP specification defines the GET method as a safe operation that simply retrieves a resource or data about a resource from the server. GET invocations do not change, create or update the state of server-side resources. Furthermore, so long as the state of the server-side resource is unchanging, the client is encouraged to cache the result.

What does the POST method do?

In contrast to GET, POST operations can send data to the server, trigger processing routines and update server-side resources. According to the HTTP 1.0 specification, a POST operation might conceivably perform the following operations:

  • Submit a form to create an order for a product.
  • Post a new message to a bulletin board.
  • Update fields in a back-end database.
  • Create a brand-new resource on the server.

However, with the release of the HTTP 1.1 protocol in 1997, the role of the POST operation became more nuanced.

The most-used HTTP methods are GET, POST, PUT, PATCH and DELETE.
The HTTP methods used most often by developers are GET, POST, PUT, PATCH and DELETE.

PUT, POST and PATCH operations

The HTTP 1.1 protocol introduced two new operations to update server-side resources: PUT and PATCH. The spec explained their use thusly:

  • A PUT operation completely and idempotently replaces a server-side resource.
  • A PATCH operation updates an existing resource at a known path.

HTTP 1.1's dictate was that developers should not use POST if a PUT or PATCH invocation makes more sense.

When to use GET vs. POST

The introduction of POST and PATCH methods adds nuance to the distinction between the GET and POST HTTP methods. It's no longer true to simply say, "GET retrieves data from the server while POST performs updates."

However, if we further say that the POST method updates should not replicate POST and PATCH behavior, the simple explanation of the difference between GET and POST invocations holds true.

Unsafe and idempotent HTTP methods.
HTTP methods including GET, POST and PUT can be categorized as unsafe, idempotent or both.

Cameron McKenzie has been a Java EE software engineer for 20 years. His current specialties include Agile development; DevOps; and container-based technologies such as Docker, Swarm and Kubernetes.

View All Videos
App Architecture
Software Quality
Cloud Computing
Security
SearchAWS
Close