Hey everyone, Iβve been nerding out a bit lately about something super fundamental to how we all experience the web: HTTP/2. Yeah, I know, sounds technical and maybe a bit dry, right? But trust me, this is actually some really cool stuff that makes your website blazing fast!
Youβve probably heard the buzzword before: βHTTP/2 is faster than HTTP/1.1.β And, sure, thatβs the basic gist of it. But itβs way more than just a speed bump; itβs like a complete makeover for how data travels across the internet. Itβs something Iβm excited about, and wanted to share it with you guys.
Why Old Faithful (HTTP/1.1) Was Starting to Slow Us Down
Okay, so before we get into all the fancy HTTP/2 stuff, letβs just quickly look back at good olβ HTTP/1.1. Itβs been our reliable internet delivery guy for ages. But times have changed! Websites have gotten way more complex and we need something better. It started showing its age in these areas:
- The One-Liner Wait: Itβs like lining up for a single coffee machine, all for each request! HTTP/1.1 can only handle one request and response at a time on each connection. So, if a really big image was loading, the rest of the page would just sit there waiting, not very productive for the visitor.
- Talking Too Much: Imagine having to say your name, address, and all your preferences every single time you ask for something. Thatβs basically how HTTP/1.1 sends headers, again and again. All that extra chit-chat slows down transfers.
- The Many Connection Hassle: The browser needs to make many requests on the same site (javascript, CSS, images etc). The browser had to make connections over and over for each type of resource, instead of using just one. This caused overhead, because it takes time to make a TCP connection.
HTTP/2: Our New Turbocharged Web Delivery System
Alright, now for the fun part! HTTP/2 fixes all those issues and adds a whole lot of magic on top. Hereβs a quick overview, and I promise, itβs going to sound pretty slick:
- Binary Not Text: Weβre throwing away text! All the request headers and payload get packaged into binary for the fastest transit and processing.
- βIβll Handle Thatβ Multiplexing: Remember the single lane problem? HTTP/2 is like adding multiple lanes. Now, many requests and responses can flow simultaneously on the same connection. Seriously, the whole thing happens so much more quickly. The site starts to βfeelβ so fast!
- Secret Message Header Compression: Weβre keeping a secret list, folks! HPACK only sends the headers that change and makes all other requests super efficient. No more having to send βaccept: /β on every single request; the browser/server remembers those kinds of header details so it doesnβt need to repeat it again.
- βFollow the Streamβ Request-Response System: With Streams each request/response pair gets an ID and we can control prioritization (with the PRIORITY Frame) for important stuff, like that crucial main stylesheet, or the biggest, juiciest image, get prioritized, first. It keeps the whole process running smoothly.
- Server Push: Like the Thoughtful Server: This is my favourite! Think of the server knowing you need extra files, and send you everything on the site, before you even ask for it. Like the CSS and crucial javascript files for all your site, delivered before your page needs it!
Cool Features Iβm Obsessed With
Okay, letβs zoom in on a couple of features that genuinely make a HUGE difference, and Iβll relate it a bit to past internet revolutions:
-
Multiplexingβs Impact: Beyond Queues
Just as HTTP/1.1 was a huge leap from HTTP/1 (where you could only process one request at a time), HTTP/2βs multiplexing is another massive jump. Think of it: In HTTP/1, a webpage felt like sending a single package one at a time, slow and clunky! HTTP/1.1 improved on this by allowing a queue of package delivery. And this gave browsers some degree of responsiveness. But HTTP/2? Itβs like having a modern logistics network with a fleet of planes delivering all the packageβs simultaneously, not one by one, or a queue. The result is just a more responsive and interactive user experience!
-
Header Compression: Clever Data Savings
Much like how you might try to abbreviate things in a text message for faster communication, HTTP/2βs header compression makes communication more concise. It uses what has previously been said to cut down on data, similar to how HTTP/1.1 addressed HTTP/1βs limitations, but taking it to a whole new level. It is another significant way HTTP/2 improves on its predecessorβs shortcomings!
-
Server Push: The Thoughtful Server
Remember dial up? HTTP 1.1 felt very similar! You requested some files, and just waited. A server with HTTP/1.1 has some hints of resources it may need to give, like CSS, or some images. But Server Push, a feature unique to HTTP/2, goes further, as a server is actively delivering everything youβll need, even without you asking. This goes beyond a slight optimization β just like HTTP/1.1 went beyond HTTP/1! This proactive server-pushing feels very new and takes responsiveness to a whole new level.
So, What Does an HTTP/2 Request Look Like in Practice?
The cool (or slightly annoying) thing is, HTTP/2 doesnβt look like those simple text lines we saw with HTTP/1.1. Everything gets neatly packed up in binary frames, not in human-readable format. I personally donβt have to work with this data as I leave it to browsers and the libraries to handle all the complexity for me. However, as a geek I can use tools to inspect and view the underlying communication process!
Wrapping Up
So thatβs the scoop on HTTP/2! Itβs the key that enables modern websites and web apps to be fast. Itβs something Iβm very keen on using and working with to help with all types of project deliveries, big or small! Also, the good news is that if you are using the latest browsers (Edge, Chrome, Firefox, etc.) then they should negotiate automatically to use this version of HTTP. Also, modern web servers (like Apache, Nginx, and others) typically offer support for HTTP/2 by default. The good news is that your web browser also automatically negotiates if your server supports HTTP/2.
A Little Teaser: The Evolution of HTTP Now, HTTP/2 builds off everything from the original HTTP (and then HTTP/1.1). HTTP has such a huge history to cover and we simply scratched the surface with this post. If you want to get into the nuts and bolts of this evolution I will be covering the history of HTTP in an upcoming post on the blog, so make sure to subscribe so you donβt miss out!
Ready to Dive In?
- Want to test if your site is using HTTP/2? Head over to [insert link to an HTTP/2 testing tool].
- Looking to implement HTTP/2 on your server? Check out [insert link to a guide or documentation].
- Have a server issue you canβt fix related to HTTP/2? Contact me and Iβd be happy to help out. [add link to contact form]
- If youβre curious about more advanced concepts around HTTP/2 and network protocols, Iβll be writing more posts on that. Make sure to sign up to my email list [add link to mailing list]
What are your experiences with HTTP/2? Any tips or questions? Letβs chat in the comments below!