HTTP Methods: GET vs POST
HTTP Methods: GET vs POST
This post was migrated from Tistory. You can find the original here.
HTTP GET vs POST
The answer to this question is mostly about
“when to use which method” — that’s the main answer, and the difference in how GET/POST actually behave feels more like a supplementary point.
When to use which method?
When we design APIs, we generally
use GET for requests that only retrieve information without changing the server’s state,
and use an appropriate method such as POST, DELETE, PUT, or PATCH for requests that do change the server’s state.
Behavioral differences
GET
- Sends data via the query string, which has a length limit and is exposed in the URL.
- Leaves a record in the browser history, and can be cached depending on server configuration.
(Of course, for caching to be possible, there has to be some record stored somewhere in the browser.)
POST
- Sends data via the body, with no limit on data size. It isn’t exposed in the URL.
(It’s just not exposed in the URL — it’s still visible if you check with dev tools, so sensitive data still needs to be encrypted before sending.) - Not recorded in the browser history, and not cached.
This post is licensed under CC BY-NC 4.0 by the author.