First, what is get and post? --Two methods of HTTP request: GET and Posthttp request Methods
The GET, POST professional name is the HTTP Request Methods. But the HTTP Request Methods is not just GET and POST, the complete list is as follows:
- GET
- POST
- PUT
- DELETE
- HEAD
- OPTIONS
- TRACE
- CONNECT
- PATCH
REST uses the top four: GET, POST, PUT, DELETE. Because these four are also often mentioned by a piece of
HTTP defines different ways to interact with the server, with 4 basic methods, namely
Get,post,put,delete。 URL full name is a Uniform Resource locator, we can think: a URL address, which is used to describe a network of resources, and HTTP Get,post,put,delete in the corresponding to the resources of the search, change, increase, delete 4 operations. Here, everyone should have a general understanding, get is generally used to get/query resource information, and post is generally used to update resource information, the earlier system because delete is not supported, so put and delete less. These are the requirements in the HTTP protocol, but in real-world development, our programmers don't seem to care about this detail. Because get post can do the job we want. So in the form (form), method defaults to "get", we simply understand that get and post are just
different delivery mechanisms, not one to take a hair!However, if you do not want to do simple function implementation, but expect to have a more powerful coding, this understanding is not enough!
Can be summarized as follows:
- Get is used only for viewing information and cannot change server information.
- POST is used to change server information.
The changes mentioned here include additions, modifications, and deletions.
This is a requirement in the HTTP protocol, and many browsers and browser plugins follow these conventions. It is recommended that programmers also use this as a benchmark in development. If your code does not follow this convention, there may be serious consequences. Here's a little history story to illustrate:
"(Introduction symbol)
Severe consequences of using GET to change server information
Suppose you write a Web program or Web site that allows GET-commit modifications, such as allowing a user to delete an order written as 1024 directly from the following Url:
~/ orders/delete/1024
Then in the Order management (or list) page, you may define a delete connection as follows:
<a href= "/orders/delete/1024" > Delete </a>
Of course, it will not be so simple, usually will prompt the user before deleting, plus the confirmation prompt script:
<a href= "/orders/delete/1024" onclick= "return confirm (' Are you sure you want to delete it? ') ' > Delete </a>
(Note: I'm just showing a simple example here, adding a confirmation to delete or recommending the use of the unobtrusive JavaScript method, you can use JQuery.) )
Many developers think this is all right, with a confirmation prompt, also not afraid of accidental deletion. But the problem is precisely here, in 2005, Google released a browser accelerator plugin: Google Web Accelerator (hereinafter referred to as GWA), so that the problem is seriously exposed.
GWA is accelerated by a variety of techniques, one of which is page preload: For example, when you view my article, GWA may download my previous or other article in the background, so that when you click, you save time and accelerate the effect.
GWA pre-loading is based on the link in the current page, according to the HTTP protocol, click the link when using the Get method to obtain information, because it does not affect the server. So GWA will be relieved to load the page that corresponds to the current page link. Of course it may also speed up the above mentioned order deletion link, GWA will disregard your confirmation delete script, directly from the background to the "/orders/delete/1024" Loading, also means that 1024 orders have been deleted.
After the release of GWA, many Web sites have a lot of puzzling problems, the data lost without reason, the product automatically added to the user's shopping cart, the user was deducted for gratuitous ...
The problem is very serious, and later found that the reason is that the Web site developers do not comply with the HTTP convention, do not understand the difference between get and POST.
You can see the following articles for an in-depth look at this history:
Http://blogs.adobe.com/cantrell/archives/2005/06/what_have_we_le.html
Http://blog.moertel.com/articles/2005/05/06/google-web-accelerator-offers-web-developers-an-important-opportunity
Now, Google's release of the Chrome browser, similar to the acceleration of the integration, you can in the settings-display advanced settings to see:
Therefore, changes to the server must be made with Post,gwa and similar plugins will not be submitted to the POST form acceleration.
Delete, view user information charges (such as talent Network, dating Network), add to the shopping cart, etc. or put it on the POST form with a Button.
I believe you will understand a lot of the explanations of Safe Methods in Wikipedia.
Note: But not all of the changes to the server to use POST, such as you click the previous post link in this article, my article access may be +1, the server has changed, but this change is slight, the impact is not small (relative deletion, debit), you can use the link (GET mode) with confidence.
“
The above is the HTTP protocol for get post but the other definition, and in the development, that is, HTML, we can also simply understand that:
1. Get uses a URL (or a cookie to pass a parameter). And the post puts the data in the body.
2. Get URLs will have a length limit, the limit is mainly the length of the URL limit, the post data can be very large.
3. Post is safer than get, data is not visible on the address bar. Parameters are not saved in the browser history or Web server log
4. For data type restrictions, get only allow ASCII characters, post no limit. also allows binary data
5.get Back button/refresh is harmless, and post data is resubmitted (the browser should tell the user that the data will be resubmitted). 6.get can be saved as a bookmark, post save and then access error
Web Development FAQ--get POST Differences