Learning HTTP/2
A Practical Guide for Beginners
Stephen Ludin and Javier Garza
Learning HTTP/2
by Stephen Ludin and Javier Garza
Copyright 2017 Stephen Ludin, Javier Garza. All rights reserved.
Printed in the United States of America.
Published by OReilly Media, Inc. , 1005 Gravenstein Highway North, Sebastopol, CA 95472.
OReilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (http://oreilly.com/safari). For more information, contact our corporate/institutional sales department: 800-998-9938 or corporate@oreilly.com .
- Acquisitions Editor: Brian Anderson
- Editors: Virginia Wilson and Dawn Schanafelt
- Production Editor: Shiny Kalapurakkel
- Copyeditor: Kim Cofer
- Proofreader: Sonia Saruba
- Indexer: Wendy Catalano
- Interior Designer: David Futato
- Cover Designer: Karen Montgomery
- Illustrator: Rebecca Demarest
Revision History for the First Edition
- 2017-05-14: First Release
See http://oreilly.com/catalog/errata.csp?isbn=9781491962442 for release details.
The OReilly logo is a registered trademark of OReilly Media, Inc. Learning HTTP/2, the cover image, and related trade dress are trademarks of OReilly Media, Inc.
While the publisher and the authors have used good faith efforts to ensure that the information and instructions contained in this work are accurate, the publisher and the authors disclaim all responsibility for errors or omissions, including without limitation responsibility for damages resulting from the use of or reliance on this work. Use of the information and instructions contained in this work is at your own risk. If any code samples or other technology this work contains or describes is subject to open source licenses or the intellectual property rights of others, it is your responsibility to ensure that your use thereof complies with such licenses and/or rights.
978-1-491-96244-2
[LSI]
Preface
HTTP/2, also called h2 for simplicity, is a major revision of the HTTP network protocol used by the World Wide Web, meant to improve the perceived performance of loading web content.
Since HTTP/1.1 (h1) was approved in 1999, the web has changed significantly from mostly text-based web pages that weighed a few kilobytes and included less than 10 objects, to todays media-rich websites that weigh on average over 2 megabytes, and include an average of 140 objects. However, the HTTP protocol used to deliver the web content did not change in the intervening years, making room for a new industry of Web Performance experts who specialize in coming up with workarounds to help the aging protocol load web pages faster. Peoples expectations for performance have changed too while in the late 90s people were willing to wait up to seven seconds for a page to load, a 2009 study by Forrester Research found that online shoppers expected pages to load under two seconds, with a large share of users abandoning sites where pages take over three seconds to load. A recent study by Google showed that a even a delay of 400 milliseconds (the blink of an eye) will cause people to search less.
Thats why h2 was created a protocol that can better handle todays complex pages without sacrificing speed. HTTP/2s adoption has been increasing as more website administrators realize they can improve the perceived performance of their websites with little effort.
We all use h2 every day it powers some of the most popular sites like Facebook, Twitter, Google, and Wikipedia but many people dont know about it. Our goal is to educate you on h2 and its performance benefits, so you can get the most out of it.
Who Should Read This Book
Regardless of your role, if you find yourself responsible for any part of the life cycle of a website, this book will be useful for you. It is intended for people building or running websites, and in general anybody considering implementing h2, or looking to understand how it works.
We expect you to be familiar with web browsers, web servers, websites, and the basics of the HTTP protocol.
What This Book Isnt
The goal of this book is to teach you h2 and help you make the most out of the new version of the HTTP protocol. It is not a comprehensive guide for all h2 clients, servers, debug tools, performance benchmarking, etc. This book is intended for people not familiar with HTTP/2, but even experts may still find it to be a convenient resource.
Recommended Resources
h2book.com is the companion website of this book, where you will find some of the examples referenced in later chapters. In addition, we recommend the following books:
- High Performance Websites, by Steve Souders (OReilly): Essential knowledge for frontend engineers
- Even Faster Websites, by Steve Souders (OReilly): Performance best practices for web developers
- High Performance Browser Networking, by Ilya Grigorik (OReilly): Hands-on overview about the various types of networks, transport protocols, application protocols, and APIs available in the browser
- Using WebPageTest, by Rick Viscomi, Andy Davies, and Marcel Duran (OReilly): Learn basic and advanced uses of WebPagetest, a free performance measurement tool for optimizing websites
- High Performance Mobile Web, by Maximiliano Firtman (OReilly): Optimize the performance of your mobile websites and webapps
- http2 explained, by Daniel Stenberg
Conventions Used in This Book
The following typographical conventions are used in this book:
Italic
Indicates new terms, URLs, email addresses, filenames, and file extensions.
Constant width
Used for program listings, as well as within paragraphs to refer to program elements such as variable or function names, databases, data types, environment variables, statements, and keywords.
Constant width bold
Shows commands or other text that should be typed literally by the user.
Constant width italic
Shows text that should be replaced with user-supplied values or by values determined by context.
Tip
This icon signifies a tip, suggestion, or general note.
Warning
This icon indicates a warning or caution.
Using Code Examples
Supplemental material (code examples, exercises, etc.) is available for download at https://github.com/oreillymedia/learning-http2.
This book is here to help you get your job done. In general, if example code is offered with this book, you may use it in your programs and documentation. You do not need to contact us for permission unless youre reproducing a significant portion of the code. For example, writing a program that uses several chunks of code from this book does not require permission. Selling or distributing a CD-ROM of examples from OReilly books does require permission. Answering a question by citing this book and quoting example code does not require permission. Incorporating a significant amount of example code from this book into your products documentation does require permission.
We appreciate, but do not require, attribution. An attribution usually includes the title, author, publisher, and ISBN. For example: Learning HTTP/2 by Stephen Ludin and Javier Garza (OReilly). Copyright 2017 Stephen Ludin and Javier Garza, 978-1-491-96244-2.