There are many ways for two (or more) computers to communicate with each other over the Internet, HTTP is just one way used to browse the web.
With the rapid development of the web, with more components than css, js … means that we will need more resources and in some cases will have to download multiple resources simultaneously. What happens when using a
In 1999, version HTTP/1.1 was released to solve this problem with the concept of pipelining. Then HTTP/1.1 version continues to be updated and used until now.
Although improved, pipelining does not completely solve the problem of HTTP/1.0. While people feel “still ok!”, In Google people feel “not ok!”, And so they released a new protocol named SPDY to improve page load time. . SPDY achieves the goal of reducing page loading time by compression, multiplexing and prioritization technologies . In July 2012, SPDY development team publicly announced that it was being developed towards standardization. Chromium, Mozilla Firefox, Opera, Amazon Silk, Internet Explorer and Safari browsers have also implemented SPDY.
As soon as SPDY was deployed, it showed significant improvement compared to HTTP/1.x and interest from developers like Firefox and nginx. Not long after that, developers began discussing HTTP/2. After a call process and selection of proposals, SPDY / 2 was chosen as the basis for HTTP/2. Since then, there have been some changes, based on discussion in the workgroup and feedback from implementers. By May 2015, HTTP/2 specification was published as RFC 7540 .
HTTP/2 is the next official version of the HTTP protocol, to improve page loading speed and performance when browsing the web.
Why not update HTTP/2?
In fact, it doesn’t matter if you don’t update HTTP/2, “everything is still ok “. The current browsers still use HTTP/1.1, if the server supports HTTP/2, then use HTTP/2.
So why care?
In general, if you are using the web, you should care.
On the user side, HTTP/2 helps make the most of bandwidth and gives a better browsing experience. If you go to a site that does not support HTTP/2, they are wasting your information, but wasting is not good!
In terms of developers, HTTP/2 support provides a better availability experience, faster page load time helps increase rankings in search engines.
Although we don’t need to know these things, we can still use HTTP/2 as usual, but knowing a little bit is better than just closing our eyes.
As mentioned above, the goal of HTTP/2 is to improve page loading speed, we will learn some characteristics that help HTTP/2 achieve this goal.
First we need to mention Multiplexed, which solved the head-of-line blocking problem that exists from HTTP/1. To make it easier to understand this issue, imagine that we go to the website like a restaurant. And when entering the restaurant, for example we will order 10 items, see how the restaurant serves us in each version:
- HTTP/1: Each server will only receive 1 order and bring it to the right item, not receive any more items. So with 10 items, we will have to call 10 service men. The restaurant just has to hire labor, but I spend time calling tired to order enough food, vl l
- HTTP/1.1: Last experience, the training restaurant of the waiters to receive more orders, but only receive 1 order 1 time, bring the item to receive the next order, be sure to forget. To order faster, you can call 2-3 more service men, depending on your needs. Overall this is quite good, easy staff training, should be used until now, each one is not optimal maximum. These guys are called persistent connections.
- HTTP/1.1: Still at this time, the restaurant has a special training staff. He works smarter than writing all the orders into the box and starting to bring things up. But this man worked a bit mechanically, had to return the items in the correct order. Unfortunately, rice, soup, fish, but all the rice will be forced to sit and wait, but do not allow fish, stale vl 🙄 In addition, the training of these guys is more difficult than the normal ones so in 2018, these guys cannot use. These guys are called pipelining connections.
- HTTP/2: If the restaurant has learned a new training technology, the employees still write all the orders in and then start bringing up the goods. But these guys will be more flexible, the ones that are first brought up first, even the bigger ones will bring each part alternately. Therefore, reducing a lot of waiting time, only 1 person can serve 1 table, reduce the cost of hiring staff.
Priority feedback (prioritization)
In HTTP/1.1, the server must send a response in the same query query order. HTTP/2 then resolves asynchronously, so smaller or faster queries can be processed sooner. Also, allow the browser to prioritize downloads for which resources are important to display the website.
For example, the <script> tag in the <head> of the page will load in Chrome at High priority (lower than CSS – Highest), but that priority will change to Low if it has an async attribute ( means it can be loaded and run asynchronously).
In addition, we can also change the priority of a resource with keywords:
Binary data transmission
HTTP / 2 transmits data in binary form instead of text like HTTP / 1.x. Binary protocols are more efficient for parsing, more compact, and most importantly, they are much less error-prone than text protocols like HTTP / 1.x. Because the binary protocol does not have to handle cases like whitespace, capitalization, line ending, blank lines …
For example, HTTP/1.1 defines four ways to analyze a message and with HTTP / 2 it is just one line of code.
There is a note that HTTP/2 cannot be used via telnet, but there are some support tools, such as the Wireshark plugin.
Header compression (header compression)
Unlike HTTP / 1.1, packet Headers will be compressed before being sent. Information sent with the query describes the data, origin, type, length … of that data. Updating ….
With servers with high latency or too large responses, we will easily see the page load time difference between HTTP / 2 and HTTP / 1. You can look at the following two examples:
- HTTP / 1.1: http://http2.golang.org/gophertiles?latency=1000
The article is a bit lengthy, but the purpose is only to introduce HTTP/2. Next article, we will try to install HTTP/2 for our server. See you again.