Understand the difference between get and post from multiple perspectives

The function is different
get: It means to get the data from the server. Generally used for query requests
post: Indicates that the submission is mainly to transmit data to the server. For general modification operations, we will use post requests,
but this is not absolute. Nowadays, many websites like to use post even for query operations, because this can save Parameters are placed in the form,
which involves the following angles

The storage location is different.
Get usually adds the parameter data queue to the url. The request body is usually empty and is visible in the url.
However, the post request data is placed in the request body and is not visible in the url. You need to view the parameters by capturing packets.

The security is different
, so it is because of the difference in the storage location that the security between them is also different

The amount of data transmitted is different.
When you search for content on Baidu, if the content you search is very long, Baidu will intercept it for you. This is because Baidu puts the content you query as a parameter in the url and uses the get request, but there is a limit on the length of the url. The parameter length is also limited. Different browsers have different url restrictions, and generally cannot be greater than 2KB.
But post is generally unrestricted by default

The encoding form is different.
If you appear Chinese in the url, it will be encoded by the url, but the request parameters will not be encoded immediately in the body of the post request.

The browser mechanism is different.
The browser will actively cache the get request and keep the history of the get request. You can view it through the history of the browser, but the post will not,
and post rollback may cause repeated submission of data.

Guess you like

Origin blog.csdn.net/qq_41286824/article/details/125406829