


99% of people misunderstand the difference between GET and POST in HTTP (reprinted
GET and POST are the two basic methods of HTTP requests. Anyone who has been exposed to WEB development can tell their differences.
The most intuitive difference is that GET includes parameters in the URL, and POST passes parameters through the request body.
You may have written countless GET and POST requests yourself, or you have read many authoritative websites summarizing their differences. You know exactly when to use which one.
When you are asked this question in the interview, your heart is filled with confidence and joy.
You easily gave a "standard answer":
-
GET is harmless when the browser rolls back, while POST submits the request again.
-
The URL address generated by GET can be Bookmarked, but POST cannot.
-
GET requests will be actively cached by the browser, but 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 parameters in POST will not be retained.
-
There is a length limit on the parameters transmitted in the URL for the GET request, but there is no length limit for POST.
-
Regarding the data type of parameters, GET only accepts ASCII characters, while POST has no restrictions.
-
GET is less secure than POST because the parameters are directly exposed on the URL, so it cannot be used to pass sensitive information.
-
GET parameters are passed through the URL, and POST is placed in the Request body.
(This standard answer is referenced from w3schools)
"Unfortunately, this is not the answer we are looking for!"
Please tell me the truth. . .
If I told you that there is essentially no difference between GET and POST, would you believe it?
Let us take off the cloak of GET and POST and be honest with each other!
What are GET and POST? Two methods of sending requests in the HTTP protocol.
What is HTTP? HTTP is a protocol based on TCP/IP about how data is communicated on the World Wide Web.
The bottom layer of HTTP is TCP/IP. So the bottom layer of GET and POST is also TCP/IP, that is to say, GET/POST are both TCP links. GET and POST can do the same thing. You need to add request body to GET and url parameters to POST. Technically, it is completely feasible.
So, what are the differences in the "standard answers"?
In our world of the World Wide Web, TCP is like a car. We use TCP to transport data. It is very reliable and there will never be any missing items. But if all the cars on the road look exactly the same, the world will look like a mess. Cars delivering urgent messages may be blocked by cars laden with goods in front of them, and the entire transportation system will definitely be paralyzed. To prevent this from happening, Traffic Rules HTTP was born. HTTP has set several service categories for car transportation, including GET, POST, PUT, DELETE, etc. HTTP stipulates that when executing a GET request, the car must be labeled with a GET (set the method to GET), and require Put the transmitted data on the roof of the car (in the url) for easy recording. If it is a POST request, a POST label must be attached to the car and the goods must be placed in the carriage. Of course, you can also secretly hide some goods in the car during GET, but this is very disgraceful; you can also put some data on the roof during POST, which makes people feel silly. HTTP is just a code of conduct, and TCP is the basis for how GET and POST are implemented.
However, we only see that HTTP imposes requirements on the transmission channel of GET and POST parameters (url or request body). Where does the limit on parameter size in the "standard answer" come from?
In my big world of the World Wide Web, there is another important role: transportation companies. Different browsers (initiating http requests) and servers (accepting http requests) are different transportation companies. Although in theory, you can pile unlimited goods on the roof of the car (unlimited parameters can be added to the URL). But transportation companies are not stupid. Loading and unloading are also very costly. They will limit the volume of a single shipment to control risks. Too much data will put a great burden on the browser and server. The unwritten rule in the industry is that (most) browsers usually limit URL length to 2K bytes, and (most) servers can handle URLs up to 64K in size. Any excess will not be processed. If you use the GET service and secretly hide data in the request body, different servers handle it differently. Some servers will help you unload and read the data, while some servers ignore it directly. Therefore, although GET can bring the request body, it cannot Guaranteed to be received.
Okay, now you know that GET and POST are essentially TCP links, there is no difference. However, due to HTTP regulations and browser/server limitations, they show some differences in the application process.
You thought this article ended like this?
Our big BOSS is still waiting to appear. . .
How mysterious is this BOSS? When you try to find "the difference between GET and POST" on the Internet, it is never mentioned in the search results you will see. What exactly is he? . .
There is another important difference between GET and POST. Simply put:
GET generates one TCP packet; POST generates two TCP packets.
The long one said:
For GET request, the browser will send the http header and data together, and the server will respond with 200 (return data);
For POST, the browser sends the header first, the server responds with 100 continue, the browser then sends data, and the server responds with 200 ok (return data).
In other words, GET only requires one trip by car to deliver the goods, while POST requires two trips. On the first trip, go and say hello to the server, "Hey, I'm going to deliver a batch of goods later. You guys?" Open the door to greet me" and then turn back to deliver the goods.
Because POST requires two steps and takes a little more time, it seems that GET is more efficient than POST. Therefore, the Yahoo team recommends replacing POST with GET to optimize website performance. But this is a trap! Jump in with caution. Why?
1. GET and POST have their own semantics and cannot be mixed casually.
2. According to research, when the network environment is good, the difference between the time of sending one package and the time of sending two packages can be basically ignored. In the case of poor network environment, TCP with two packets has great advantages in verifying the integrity of data packets.
3. Not all browsers will send the package twice in POST, Firefox only sends it once.
Now, when the interviewer asks you "the difference between GET and POST" again, is this what you feel in your heart?
(This article is original, please indicate that it is from the WeChat public account WebTechGarden)
(If there are any mistakes in the article, please feel free to correct them)

The future trends of HTML are semantics and web components, the future trends of CSS are CSS-in-JS and CSSHoudini, and the future trends of JavaScript are WebAssembly and Serverless. 1. HTML semantics improve accessibility and SEO effects, and Web components improve development efficiency, but attention should be paid to browser compatibility. 2. CSS-in-JS enhances style management flexibility but may increase file size. CSSHoudini allows direct operation of CSS rendering. 3.WebAssembly optimizes browser application performance but has a steep learning curve, and Serverless simplifies development but requires optimization of cold start problems.

The roles of HTML, CSS and JavaScript in web development are: 1. HTML defines the web page structure, 2. CSS controls the web page style, and 3. JavaScript adds dynamic behavior. Together, they build the framework, aesthetics and interactivity of modern websites.

The future of HTML is full of infinite possibilities. 1) New features and standards will include more semantic tags and the popularity of WebComponents. 2) The web design trend will continue to develop towards responsive and accessible design. 3) Performance optimization will improve the user experience through responsive image loading and lazy loading technologies.

The roles of HTML, CSS and JavaScript in web development are: HTML is responsible for content structure, CSS is responsible for style, and JavaScript is responsible for dynamic behavior. 1. HTML defines the web page structure and content through tags to ensure semantics. 2. CSS controls the web page style through selectors and attributes to make it beautiful and easy to read. 3. JavaScript controls web page behavior through scripts to achieve dynamic and interactive functions.

HTMLisnotaprogramminglanguage;itisamarkuplanguage.1)HTMLstructuresandformatswebcontentusingtags.2)ItworkswithCSSforstylingandJavaScriptforinteractivity,enhancingwebdevelopment.

HTML is the cornerstone of building web page structure. 1. HTML defines the content structure and semantics, and uses, etc. tags. 2. Provide semantic markers, such as, etc., to improve SEO effect. 3. To realize user interaction through tags, pay attention to form verification. 4. Use advanced elements such as, combined with JavaScript to achieve dynamic effects. 5. Common errors include unclosed labels and unquoted attribute values, and verification tools are required. 6. Optimization strategies include reducing HTTP requests, compressing HTML, using semantic tags, etc.

HTML is a language used to build web pages, defining web page structure and content through tags and attributes. 1) HTML organizes document structure through tags, such as,. 2) The browser parses HTML to build the DOM and renders the web page. 3) New features of HTML5, such as, enhance multimedia functions. 4) Common errors include unclosed labels and unquoted attribute values. 5) Optimization suggestions include using semantic tags and reducing file size.

WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Linux new version
SublimeText3 Linux latest version

Dreamweaver Mac version
Visual web development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SublimeText3 Mac version
God-level code editing software (SublimeText3)