The difference between GET and POST and casually talk about cache

GET and POST

First of all! It must be said!

GET and POST are essentially the same. GET and POST are a kind of TCP connection, but GET generates 1 TCP data packet, and POST generates two data packets.

GET is to send the http header and data together at once, and the server responds with 200.
POST is sent in two times, the first time the http header is sent, the server responds with 100, and the second time data is sent, the server responds with 200 ok.

In the form of expression
1) GET parameters are passed through the URL, while POST puts the data in the request body.
2) GET request parameters will be completely retained in the browser history, while POST parameters will not be retained.
3) GET has a length limit, and POST does not.
4) GET is more insecure than POST because the parameters are all displayed in the URL.
5) The URL address generated by GET can be bookmarked, but POST cannot. (In layman's terms, you can see GET in the browsing record)
6) Regarding the data type of the parameter, GET only accepts ASCII characters, while POST has no restrictions.
(URL is a header of HTTP. Since it is a header, it must be ASCII characters according to the agreement.)
7) GET request will be cached by the browser actively, but POST will not, unless manually set.
(Browser cache is divided into strong cache and negotiation cache. Just open a webpage, some pictures on the webpage will be downloaded to the local internet temporary folder, when you open it again, it may be Not to open the web page from the Internet, but to read it directly from the local.)

Let's talk about cache casually

Browser caching is to reduce unnecessary requests.

HTTP cache is divided into strong cache and negotiation cache

A strong cache is to force the use of the cache. As long as the cache time has not expired, the server will no longer be accessed and the data will be obtained in the local cache.

Negotiation cache is to confirm with the server whether the data is updated or changed, if not, the local server will be used, and the new data will be requested if it is changed.

Guess you like

Origin blog.csdn.net/d1063270962/article/details/109608670