GET / POST difference

a) parameters:

  GET parameters passed with only behind URL, text format QueryString, various browsers generally have length restrictions, generally considered to be 2083, if there are Chinese characters shorter. A small amount of data submitted to the server.

 POST can pass application / similar QueryString x-www-form-urlencoded is, multipart / form-data packet binary formats (file information is embedded message transmission), body parameters plain text or binary. Submit to the large amount of data on the server side. Reference: http://blog.csdn.net/kimmking/article/details/2051169

b) Uses:

 GET used to retrieve data from the server, including static resources (HTML | JS | CSS | Image, etc.), dynamic data presentation (list data, the details of data, etc.).

  POST is used to submit data to the server, such as additions and deletions to the data, a user submits a form new, or modify a user or the like.

c) cache:

  GET default cache as a result may be multiplexed with the previously requested data returned, this time in a complete URL as cache data when the KEY. So sometimes in order to force every time new data request, we can add a timestamp or random parameter Math.random new Date (). GetTime (), or version number behind URL, such as abc.com?a=1&rnd = 0.123987 and the like. This is also behind some static resource plus a long version number of reasons, jquery-min.js? V = 13877770 represents one version, when the page references jquery-min.js? V = 13,877,771 browser when the server is bound to go again request this resource. jQuery.ajax method, if the cache = false, additional parameters will be in the GET request "_ = {timestamp}" to disable the cache.

 POST generally will not be affected by these factors cache.

d) Security:

 The default for the access log nginx will automatically record the full URL get or post, including the parameters belt.

 For POST, the request message has not been recorded for these sensitive data, the POST safer.

e) automated performance tests:

  Based on the above-mentioned nginx logs, may be used grep GET + date, awk format, and then to re-sort -u to extract all day to a GET request URL, login using simulation program, and then request all the acquired URL to simple performance test data, each request is correct, in response to how much time and so on.

  But for POST requests, because they do not know the message, not so simple process. Messages can be output nginx-lua get through to the log, this format will be a lot of trouble, but it would be a way.

Guess you like

Origin www.cnblogs.com/SallyShan/p/11488758.html
Recommended