The difference between POST and GET

1.GET is harmless when the browser falls back, whereas POST resubmits the request.

2. The URL generated by GET can be bookmarked, but not by POST.

3.GET requests are actively cached by browsers, but POST requests are not, unless manually set.

4. Only URL encoding can be used for GET requests, while POST supports multiple encoding modes.

5. The parameters of the GET request are fully preserved in the browser history, while the parameters of the POST request are not.

6.GET requests pass parameters in the URL with length limits, whereas POST does not.

7. For data types of arguments, GET accepts only ASCII characters, while POST has no limit.

8.GET is less secure than POST because parameters are exposed directly to the URL and therefore cannot be used to pass sensitive information.

9. The GET parameter is passed through the URL and the POST is placed in the Request body.

What are GET and POST

Two methods of sending a request in HTTP

HTTP is a TCP/ IP-based protocol for how data is communicated on the World Wide Web.

The underlying layer of HTTP is TCP/IP. So the bottom layer of GET and POST is also TCP/IP, that is, both GET and POST are TCP links. GET and POST can do the same thing

The essential difference

There is another important player in the world wide Web: transportation companies. Different browsers (making HTTP requests) and servers (accepting HTTP requests) are different shipping companies. In theory, though, you can stack an infinite amount of goods on the roof (with an infinite number of parameters in the URL). But shipping companies are not stupid. Loading and unloading costs are high, and they limit the risk of a single shipment. Too much data is a burden on browsers and servers. The unwritten rule of the industry is that (most) browsers generally limit urls to 2K bytes, while (most) servers handle urls up to 64K. Any excess will not be processed. If you use the GET service to hide data in the request body, different servers will handle it differently. Some servers will load the data for you and read it, while others will ignore it. Therefore, although GET can contain the request body, there is no guarantee that it will be received.

GET generates a TCP packet. The browser sends HTTP headers and data together. The server responds with 200 (return data).

POST generates two TCP packets. The browser sends a header, the server responds with 100 continue, the browser sends data, and the server responds with 200 OK (returns data).

Pay attention to the point

  1. According to research, under the condition of good network environment, the time difference between sending a packet and sending two packets can be ignored basically. In the case of poor network environment, the TCP of two packets has great advantages in verifying the integrity of packets.

  2. Not all browsers send packages twice in POST, Firefox only sends them once.