Let's consider a Web page test.html located at
https://example.com/test.html which uses a CSS sheet style.css and includes 3 images a.jpg, b.jpg and c.jpg.
If a HTTP/1.1 browser visits
https://example.com/test.html, it will:
- Open a TCP/IP connection to example.com
- Negociate an SSL/TLS session
- Send a request for virtual path /test.html
- Receive the reply and parse the page
- Reuse the same connection to send a new request for /style.css
- Receive the reply
- Open a TCP/IP connection to example.com
- Negociate an SSL/TLS session
- Use the new connection to request /a.jpg
- Reuse the new connection to request /b.jpg
- Reuse the first connection to request /c.jpg
- Close both connections
If a HTTP/2 browser visits
https://example.com/test.html, it will:
- Open a TCP/IP connection to example.com
- Negociate an SSL/TLS session
- Send a request for virtual path /test.html
- Receive the reply and parse the page
- Send a request for /style.css
- Send a request for /a.jpg
- Send a request for /b.jpg
- Send a request for /c.jpg
- Receive the replies for all requested files
- Close the connection
In this small example, HTTP/2 has used a single TCP/IP connection with a single SSL/TLS negociation while HTTP/1.1 required two of each.
The total time to load the page with its dependencies is also shorter.