There are many advantages to post compared to get, why do most requests in HTTP traffic now use Get?

Source: Internet
Author: User
Tags representational state transfer

Well, in addition to the philosophical way of answering, here is the view of a browser practitioner

In fact, get and POST have a very big difference in practice, and these two methods are not interchangeable in semantics.

POST is safer than GET

Yes, post is a little bit safer than get, note, is a little bit ...

It's not wrong to say that both are clear text, but here's the detail that get URLs are placed in the browser history and Web server logs.

Post after the basic on the wood has.

So if you put the key data in get inside, was peeping the browser, or the Web server was hacked log by people, the basic leak probability 100%. and post, the log is not recorded, as long as the database server is not compromised, the basic is still safe.

Of course, if the bag is caught, all this has no egg use, so, HTTPS is used or used.


What is the advantage of GET versus POST?

The biggest advantage is that get URL can be human hand lose ah ... You put a post in the address bar to see me. Essentially, all of the GET information is in the URL, so it's convenient to record it and reuse it.

So if you want to
-the URL in the request can be entered manually
-the URL in the request can be in the bookmark, or history, or speed dial inside, or share to others.
-the URL in the request can be indexed by the search engine.
-Browser with cloud compression, such as Opera Mini/turbo 2, only get can be pre-fetch on server side.
-the URL in the request can be cached.

Please use GET.

People have not noticed, in fact, there are many aspects of the requirements are related to the operation of the site, rather than technology-related. Any technical behavior, in fact, more or less can see the shadow of business.

Instead, use post. In particular, there are some things you don't want people to be able to enter in the browser address bar. For example, if you design a blog system, design such a URL to remove all posts.

http://myblog.com/?action=delete_all


I can only say that soon you will know what does not die will not die this reason, search engine crawler minutes teach you to behave.

Another criterion is that you can repeat the interaction, such as taking a data, jumping a page, and using GET.
You can not repeat the operation, such as create an entry/modify a record, with post, because post cannot be cached, so the browser will not be submitted multiple times.

The Web API is designed to be more complex than web pages, and there are get/post problems, and the main accepted method is restful, see here

Representational State transfer

This is the trend:


At the same time, for when to use get, there is also an article of the paper specifically explained:
http://www. w3.org/2001/tag/doc/whentouseget.html

Pick a little bit out:

1.3 Quick Checklist for choosing HTTP GET or POST

  • Use GET if:
    • The interaction is more like a question (i.e., it is a safe operation such as a query, read operation, or lookup).

and

  • Use POST if:
    • The interaction is more like an order, or
    • The interaction changes the state of the resource in a, the the user would perceive (e.g., a subscription to a service ), or o the user is held accountable for the results of the interaction.

However, before the final decision to use HTTP GET or POST, please also consider considerations for sensitive data and PRA Ctical considerations.

*************************************************************************************************************** *********************

Because they express different semantics, this determines that the backbone network can handle it differently.

Get is an idempotent, read-only, pure operation that, in addition to returning results, should not produce other side effects (such as writing a database), so most get requests (usually more than 90%) are cached directly by the CDN, which can greatly reduce the burden on the Web server. While the semantics expressed by post are non-idempotent and have side effects, they must be processed by the Web server.

Changing all the Get requests to post means that all the CDN on the backbone network has been discarded and the number of requests the Web server is going to process will increase hundreds and thousands of times, which is obviously not a smart idea!

-------------------------Split line in circles-----------------------

I think the above explanation is enough for a person who is genuinely talking about a problem, but some people have to circle the circles, so I'll go around the circle with you. "Get and post is the difference between those letters" the students who have developed Web servers know that as long as the request hits the server, So how to explain the content of this request is entirely the server's own business, but the Web server development framework will usually help you to do something to resolve the HTTP request. So if the client and the service are written on their own, it is of course very casual, how to play on how to play well, in fact, no restful advice, we did play very casually.

But to say "just a few letters" is just an expression of the meaning of "I've worked on server development." The real difficulty with the problem is that the number of requests per day on the network is huge, and the vast majority of these requests are read-only, which is a huge waste of resources if all of these requests are addressed directly to the Web server. So it is natural to think that if we can request to the Web server before the request to make a preliminary analysis, the general intent of the request, for different intentions of the request in different ways to meet (such as the request through Nginx, Nginx will parse the request header information, Then it is much more reasonable to assign the request to the appropriate role for further processing based on this information. So restful advice came into being at this time, and it was in order to solve the problem that the HTTP infrastructure could not be fully used properly.

So when we develop a service, we choose the HTTP protocol (not directly with TCP), the most fundamental reason is that we want it to work directly with the browser, can borrow the existing HTTP infrastructure, its behavior can be in addition to their own clients, other roles in the network understand. (instead of just HTTP to solve text encoding problems, that's why we emphasize the difference between get and post, and emphasize the "semantics" of the real reason.)

References

http://www.zhihu.com/question/31640769

Post has many advantages over get, why do most requests in HTTP traffic now use Get?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.