HTTP request method: the difference between GET and POST and usage scenarios

the difference:

  • GET is harmless when the browser rolls back, and has no persistent side effects, such as searching; while POST will submit the request again, with side effects, such as adding new data rows to the database.

  • The URL address generated by GET can be Bookmarked, but not by POST.

  • GET requests will be actively cached by the browser, while POST will not, unless manually set.

  • GET requests can only be url-encoded, while POST supports multiple encoding methods.

  • GET request parameters will be completely retained in the browser history, while POST parameters will not be retained.

  • The parameters transmitted in the URL for GET requests are limited in length, while POST does not.

  • For the data type of the parameter, GET only accepts ASCII characters, while POST has no restrictions.

  • GET is less secure than POST, because parameters are directly exposed on the URL, so it cannot be used to transmit sensitive information.

  • GET is faster than POST.

scenes to be used:

  GET request:

  • Hope that the URL in the request can be entered manually

  • I hope that the URL in the request can be saved in the bookmark, or in the history, or in the speed dial, or shared with others.

  • Hope that the URL in the request can be indexed by search engines.

  • I want browsers with cloud compression, such as Opera mini/Turbo 2, only GET can be prefetched on the server side.

  • Hope that the URL in the request can be cached

  POST request:

  • Form submission.

  • There is sensitive information in the request parameters.

  • The request parameters are very long and may exceed the limit of the browser or server.

In general, GET is suitable for query operations, and POST is suitable for adding, modifying, and deleting operations.

 

 

Guess you like

Origin blog.csdn.net/liangmengbk/article/details/108948776