search
HomeWeb Front-endHTML TutorialUnderstand HTTP, HTTPS, SPDY, HTTP2 at once


The content of this article is about understanding HTTP, HTTPS, SPDY, and HTTP2 at one time. It has certain reference value and should be used if necessary. Friends can refer to it, I hope it will be helpful to you.

Understand HTTP, HTTPS, SPDY, HTTP2 at once

As a veteran of Internet communication protocols, the HTTP protocol has gone through three version changes today. The latest version is HTTP2.0, which I believe everyone is familiar with. . Today I will give you a good introduction to the past and present of HTTP.

HTTP/0.9

The earliest version of HTTP was born in 1991. This earliest version is extremely simple compared to now, with no HTTP header, no status code, and even version There was no number, and later its version number was set to 0.9 to distinguish it from other versions of HTTP. HTTP/0.9 only supports one method - Get, and the request has only one line.

GET /hello.html
The response is also very simple, only containing the html document itself.

<HTML>
Hello world
</HTML>

When the TCP connection is established, the server returns a string in HTML format to the client. After sending, close the TCP connection. Since there are no status codes and error codes, if an error occurs during server processing, only a special HTML file containing problem description information will be returned. This is the earliest version of HTTP/0.9.

HTTP/1.0

In 1996, the HTTP/1.0 version was released, which greatly enriched the transmission content of HTTP. In addition to text, you can also send pictures, videos, etc. This It laid the foundation for the development of the Internet. Compared with HTTP/0.9, HTTP/1.0 mainly has the following features:

Requests and responses support HTTP headers, status codes are added, and the beginning of the response object is a response status line

Protocol version Information needs to be sent along with the request, supporting HEAD and POST methods

Supports transmitting other types of content besides HTML files

A typical HTTP/1.0 request looks like this:

GET /hello.html HTTP/1.0
User-Agent:NCSA_Mosaic/2.0(Windows3.1)
200 OK
Date: Tue, 15 Nov 1996 08:12:31 GMT
Server: CERN/3.0 libwww/2.17
Content-Type: text/html
<HTML>
一个包含图片的页面
<img  src="/static/imghwm/default1.png"  data-src="/smile.gif"  class="lazy" alt="Understand HTTP, HTTPS, SPDY, HTTP2 at once" >
</HTML>

HTTP/1.1


HTTP/1.1 was released a few months after HTTP/1.0. HTTP/1.1 is more of an improvement on HTTP/1.0. In HTTP1.1, it mainly has the following improvements:

Can reuse connections

Add pipeline: HTTP pipeline is to A technology that submits multiple HTTP requests in batches without waiting for a response from the server during transmission. The pipeline mechanism must be completed through a persistent connection. The browser's batch submission of HTTP requests can greatly shorten the page loading time, especially when the transmission delay (lag/latency) is high. One thing to note is that only idempotent requests can use the pipeline, such as GET and HEAD methods.

Chunked encoding transmission: This encoding transmits the entity in chunks and indicates the length block by block until the length is 0 blocks indicating the end of the transmission. This is particularly useful when the length of the entity is unknown (such as data dynamically generated by the database)

Introduce more cache control mechanisms: such as etag, cache-control

Introduce content negotiation mechanisms, including language, encoding, type, etc., and allow the client and server to agree on the most appropriate Content exchange

Both request messages and response messages support the Host header field: In HTTP1.0, each server is considered to be bound to a unique IP address. Therefore, the URL in the request message does not pass the host name. (hostname). However, with the development of virtual host technology, multiple virtual hosts (Multi-homed Web Servers) can exist on a physical server, and they share an IP address. Therefore, the introduction of the Host header is necessary.

Added OPTIONS, PUT, DELETE, TRACE, CONNECT methods

Although HTTP/1.1 has been optimized in many points, as the most widely used protocol version, it can already satisfy many networks However, as web pages become more and more complex and even evolve into independent applications, HTTP/1.1 gradually exposes some problems:

When transmitting data, the connection must be re-established every time, which is The mobile terminal is particularly unfriendly

The transmission content is plain text, which is not secure enough

The header content is too large, and the header does not change much every time the request is made, causing waste

keep-alive to the service The end brings performance pressure

In order to solve these problems, HTTPS and SPDY came into being.

SPDY

In fact, SPDY is not a new protocol, but a session layer before HTTP.

Between 2010 and 2015, Google demonstrated an alternative way of exchanging data between the client and server by implementing an experimental SPDY protocol. It captures the focus of browser and server-side developers, clarifies the increase in response volume and solves the complexity of data transfer. The default goal when starting the SPDY project is:

Reduce page load time (PLT) by 50%.

No need for the website author to modify any content.

Minimize deployment complexity without changing network infrastructure.

Working with the open source community to develop this new protocol.

Collect real performance data to verify whether this experimental protocol is effective.

In order to achieve the goal of reducing page load times, SPDY introduces a new binary framing data layer to enable multi-directional requests and responses, prioritize, minimize and eliminate unnecessary network delays, with the goal of Make more efficient use of underlying TCP connections.

HTTP/2.0

In 2015, HTTP/2.0 came out. Let’s first introduce the characteristics of HTTP/2.0:

Use binary framing layer: Add a binary framing layer between the application layer and the transport layer to achieve the HTTP method without changing the semantics of HTTP. , status code, URI and header fields, break through the performance limitations of HTTP1.1, improve transmission performance, and achieve low latency and high throughput. At the binary framing layer, HTTP2.0 will divide all transmitted information into smaller messages and frames, and encode them in binary format. The header information of HTTP1.x will be encapsulated into the Headers frame, and we The request body is encapsulated into the Data frame.

Binary Framing

Multiplexing: For HTTP/1.x, even if a long connection is enabled, the request is sent serially. When the bandwidth is sufficient, The utilization rate of bandwidth is not enough. HTTP/2.0 adopts multiplexing method, which can send multiple requests in parallel to improve the utilization rate of bandwidth.

Multiplexing

Data flow priority: Since requests can be sent concurrently, if the browser is waiting for key CSS or JS files to complete rendering of the page, the server What should I do if I am focusing on sending picture resources? HTTP/2.0 can set a priority value for data flows. This priority value determines the different priority strategies used by the client and server to process different flows.

Server-side push: In HTTP/2.0, the server can send content other than the request to the client. For example, when a page is being requested, the server will push the page-related logo, CSS and other files directly to the client. , instead of waiting until the request comes before sending it, because the server thinks that the client will use these things. This is equivalent to gathering all resources in one HTML document.

Header compression: Use the header table to track and store previously sent key-value pairs. The same content will not be sent in each request and response.

The above is a complete introduction to understanding HTTP, HTTPS, SPDY, and HTTP2 at one time. If you want to know more about Html5 tutorial, please pay attention to the PHP Chinese website.



The above is the detailed content of Understand HTTP, HTTPS, SPDY, HTTP2 at once. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:segmentfault. If there is any infringement, please contact admin@php.cn delete
The Future of HTML: Evolution and TrendsThe Future of HTML: Evolution and TrendsMay 13, 2025 am 12:01 AM

The future of HTML will develop in a more semantic, functional and modular direction. 1) Semanticization will make the tag describe the content more clearly, improving SEO and barrier-free access. 2) Functionalization will introduce new elements and attributes to meet user needs. 3) Modularity will support component development and improve code reusability.

Why are HTML attributes important for web development?Why are HTML attributes important for web development?May 12, 2025 am 12:01 AM

HTMLattributesarecrucialinwebdevelopmentforcontrollingbehavior,appearance,andfunctionality.Theyenhanceinteractivity,accessibility,andSEO.Forexample,thesrcattributeintagsimpactsSEO,whileonclickintagsaddsinteractivity.Touseattributeseffectively:1)Usese

What is the purpose of the alt attribute? Why is it important?What is the purpose of the alt attribute? Why is it important?May 11, 2025 am 12:01 AM

The alt attribute is an important part of the tag in HTML and is used to provide alternative text for images. 1. When the image cannot be loaded, the text in the alt attribute will be displayed to improve the user experience. 2. Screen readers use the alt attribute to help visually impaired users understand the content of the picture. 3. Search engines index text in the alt attribute to improve the SEO ranking of web pages.

HTML, CSS, and JavaScript: Examples and Practical ApplicationsHTML, CSS, and JavaScript: Examples and Practical ApplicationsMay 09, 2025 am 12:01 AM

The roles of HTML, CSS and JavaScript in web development are: 1. HTML is used to build web page structure; 2. CSS is used to beautify the appearance of web pages; 3. JavaScript is used to achieve dynamic interaction. Through tags, styles and scripts, these three together build the core functions of modern web pages.

How do you set the lang attribute on the  tag? Why is this important?How do you set the lang attribute on the tag? Why is this important?May 08, 2025 am 12:03 AM

Setting the lang attributes of a tag is a key step in optimizing web accessibility and SEO. 1) Set the lang attribute in the tag, such as. 2) In multilingual content, set lang attributes for different language parts, such as. 3) Use language codes that comply with ISO639-1 standards, such as "en", "fr", "zh", etc. Correctly setting the lang attribute can improve the accessibility of web pages and search engine rankings.

What is the purpose of HTML attributes?What is the purpose of HTML attributes?May 07, 2025 am 12:01 AM

HTMLattributesareessentialforenhancingwebelements'functionalityandappearance.Theyaddinformationtodefinebehavior,appearance,andinteraction,makingwebsitesinteractive,responsive,andvisuallyappealing.Attributeslikesrc,href,class,type,anddisabledtransform

How do you create a list in HTML?How do you create a list in HTML?May 06, 2025 am 12:01 AM

TocreatealistinHTML,useforunorderedlistsandfororderedlists:1)Forunorderedlists,wrapitemsinanduseforeachitem,renderingasabulletedlist.2)Fororderedlists,useandfornumberedlists,customizablewiththetypeattributefordifferentnumberingstyles.

HTML in Action: Examples of Website StructureHTML in Action: Examples of Website StructureMay 05, 2025 am 12:03 AM

HTML is used to build websites with clear structure. 1) Use tags such as, and define the website structure. 2) Examples show the structure of blogs and e-commerce websites. 3) Avoid common mistakes such as incorrect label nesting. 4) Optimize performance by reducing HTTP requests and using semantic tags.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Article

Hot Tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),