Get & PSOt are HTTP request types

1. The amount of data sent

In GET, only a limited amount of data can be sent because the data is sent in the URL. In POST, a large amount of data can be sent because the data is sent in the positive subject (the request header).Copy the code

2. The security

The data sent by the GET method is not protected, because the data is public in the URl bar, which undoubtedly increases the risk of vulnerabilities and hacker attacks. The data sent by the POST method is secure, because the data is not public in the URl bar, and multiple encoding techniques can be used in the data, which is flexible and flexible.Copy the code

3. Add them to bookmarks

The result of a GET query can be bookmarked because it exists as a URl, whereas the result of a POST query cannot be bookmarked.Copy the code

4. The coding

When you use the GET method on a form, only ASCII characters are accepted in the data type. When a form is submitted, the POST method does not bind data types and allows binary and ASCII characters.Copy the code

5. Variable size

The variable size in the GET method is about 2000 characters. The maximum variable size allowed in the POST method is 8MB.Copy the code

6. The cache

Get data can be cached. Post data cannot be cachedCopy the code

7. Main functions

The GET method is used to obtain information, that is, to query information, but the plaintext cannot be used to submit confidential information. The POST method is mainly used to update data, that is, to submit common forms, and even to transfer files without transmission restrictions, which is safeCopy the code

Supplement knowledge

Error in the length of get request parameters
We often say that get request parameters have a limited size, while POST request parameters have an unlimited size. The actual HTTP protocol never specifies a length limit for GET/POST requests. The constraints on get request parameters are the source and browser or Web server,Copy the code
The browser or Web server limits the length of the URL. To clarify this concept, the following points should be emphasized:
1.HTTP protocol does not specify length limits for GET and POST. 2. The maximum length of GET is displayed because browsers and Web servers limit URI length 3. The maximum length varies with browsers and WEB servers. 4. If Internet Explorer is supported, the maximum length is 2083 bytes; if only Chrome is supported, the maximum length is 8182 bytesCopy the code
Cache differences between GET and POST requests
Get requests are similar to lookups in that the user retrieves data without having to connect to the database every time, so caching can be used. Unlike Post, which generally does modification and deletion, it must interact with the database, so it cannot use caching. Therefore, GET requests are suitable for request caching. Caching is generally only applicable to requests that do not update server data. Generally, GET requests are search requests and do not modify server resource data, whereas POST requests generally modify server data. Therefore, GET requests are generally cached, but POST requests are rarely cached.Copy the code