The shop's page is slow, and you press the Buy button twice by accident. So did you buy one pair of shoes or two? The answer depends on the verb in the request letter that the button sends.
GET fetches, POST sends
- GET only fetches. Opening a page, searching, going to page 2: all of them use GET. GET changes nothing at MyShop, so sending the same GET ten times is still safe.
- POST sends something new: an order, a comment, a new account. Every POST that arrives makes one new record on the server.
The Buy button sends a POST. That is why pressing Buy twice can become two orders: two POSTs, two order slips. A careful shop locks the Buy button after one press, or gives every order a number: two POSTs with the same number mean a double order.
💡 Other verbs
Besides GET and POST, there are verbs to replace (PUT), to change a part (PATCH) and to delete (DELETE). The In Depth part covers all three.
TL;DR: GET and POST are two verbs in a request letter. GET fetches without changing anything, so repeating it is safe. POST sends something new, such as an order, so every POST that arrives makes one new record on the server.
⚡ GET only fetches
Meaning: In a request letter, GET is the verb that only fetches. Opening a page, searching, going to page 2: all of them use GET. GET changes nothing on the server, so sending the same GET ten times is still safe.
⚡ POST sends something new
Guess first: every POST that arrives makes one new record on the server. The page is slow, and you press the Buy button twice. That button sends a POST. How many orders are recorded?
Two. Two presses mean two POSTs, so two new orders.
Meaning: POST is the verb for sending something new: an order, a comment, a new account. A careful shop locks the Buy button after one press, or gives every order a number: two POSTs with the same number mean a double order.
⚡ Other verbs
Meaning: There are also verbs to replace (PUT), to change a part (PATCH) and to delete (DELETE). The In Depth part covers all three.