EKsumic's Blog

let today = new Beginning();

Click the left button to use the catalog.

OR

Difference between HTTP GET and HTTP POST method

1. Generally speaking, GET is to obtain data, and POST is to submit data. But because GET and POST are both HTTP methods, HTTP is a TCP/IP-based protocol on how data communicates on the World Wide Web. So in essence, there is no difference between GET and POST requests. They are all TCP connections. What they can do is the same. Now that the HTTP protocol has these two methods, it is to distinguish applications under specific circumstances. So what we call GET is to get data, and POST is to submit data.

2. When GET transmits data, it is in the URL address, which is visible to everyone, is insecure, and has a browser cache record. So GET is insecure. Don't use GET to transmit data such as passwords.
GET can only transmit ASCLL characters, not encoding.
When POST is transmitted, it is placed in the HTTP request body, and it is urlencode encoded, so it is relatively safe.
POST has no restrictions on data types, and binary data is also possible.

3. The HTTP protocol does not limit the length of GET and POST. In fact, the browser limits their transmission size.

URL addresses have length restrictions, and the specific values of different length restrictions on browsers are also different. For example, IE is 2083 bytes. Note that these are only limitations on the length of the URL address bar.

Theoretically speaking, there is no limit to the length of POST, but due to server configuration limitations or memory size limitations, POST also has data length limitations in actual development. You can modify the postmaxsize value in php.conf under PHP to set the POST size.

4.

Why is GET faster than POST?

One reason is that POST needs to include data in the body part of the request, so there will be a few more header fields in the description part such as content-type, but this is negligible and can be ignored.

Another reason is that the process of POST and GET requests is different.

POST request process:

It performs a 3-way handshake first, and then the server returns a 100continue response, the browser sends the data again, and the server returns a 200 success response.

GET request process:

It is also an advanced 3-way handshake, and then the server returns a successful response.

That is to say, POST requires one more data transmission than GET, so GET requests are faster than POST requests.

But in the current situation of higher server configuration and faster network speed, this extra data transmission has no effect in practice.


5. Because GET is to obtain data, GET requests are safe and idempotent, and are harmless. This security means that it will not affect the data. In simple terms, idempotence means that the resources obtained are the same no matter how many times the data is obtained.

POST is to transmit data to the server, the data will be resubmitted, so it will cause harm to the original data.

The above is my summary about the difference between POST and GET. Please correct me if there are errors.

This article was last edited at 2020-10-29 22:01:59

* *