Front-end learning: the difference between get and post

The difference between get and post

This question is often encountered during interviews. The following is a record of my learning process for reference.

1. Based on what premise?

1.1 No prerequisites

If there are no prerequisites, no specification is used, only http syntax and theoretical http protocol are considered.
There is no difference between get and post

1.2 Premise based on RFC specification

1) In theory:

get and post have the same syntax, but different semantics, get is used to get data, post is used to send data. otherwise no difference

2) In terms of implementation:

In terms of implementation, http is just a format, and someone needs to parse and use this format. For example, various browsers are implementers of this format, but not only browsers can be implementers. There are these common differences on browser-based:
the difference
(1) The get data is visible on the URL, but the post is not visible on the URL.
(2) The length of the get request is limited (many times it has to be placed in the address bar, which cannot store so many numbers), and the length of the post request is unlimited.
(3) The data requested by get can be collected as tags, but the data requested by post cannot be collected as tags.
(4) After the get request, if you press the back button or the refresh button, it will have no effect, but the post data will be resubmitted.
(5) Get encoding type: application/x-www-form/url
post encoding type (he has many types):
encodeapplication/x-www-form-urlencoded
multipart/form-data
(6) The historical parameters of get will be preserved In the browser, but the post will not
(7) the get request only allows ASCII encoding, the post request has no encoding restrictions, and binary is allowed.
(8) Compared with post, get is less secure.

2. Summary

The above is my study record. What is the difference between get and post? Welcome to add.

Guess you like

Origin blog.csdn.net/TotoroChinchilla/article/details/125319604