From: Rich Bowen
There has been a lot written about HTTP/2 and how it works. The most normative is, of course,
- its
But, as RFCs do, it's not really a good thing to read first. It's better to first understand - what a thing wants to do and then read the RFC about how it is done. A much - better document to start with is http2 explained - by Daniel Stenberg, the author of curl. It is available in - an ever growing list of languages, too!
-TL;DR: there are some new terms and gotchas that need to be kept in + +
The protocol is defined in
In short: there are some new terms and gotchas that need to be kept in mind while reading this document:
+libnghttp2 installed on your system.
When you ./configure your Apache httpd source tree, you need to give it
'--enable-http2' as additional argument to trigger the build of the module.
@@ -111,32 +112,32 @@
basic configuration for it becoming active. The first thing, as with every httpd module,
is that you need to load it:
The second directive you need to add to your server configuration is
This allows h2, the secure variant, to be the preferred protocol on your server - connections. When you want to enable all HTTP/2 variants, you simply write:
+ connections. When you want to enable all HTTP/2 variants, write:Depending on where you put this directive, it affects all connections or just - the ones to a certain virtual host. You can nest it, as in:
+Depending on where you put this directive, it affects all connections or only + those to a specific virtual host. You can nest it, as in:
The h2 enabled server with an inappropriate
- cipher suite will force it to simply refuse and fall back to HTTP 1.1. This is a common mistake
+ cipher suite causes it to refuse and fall back to HTTP 1.1. This is a common mistake
made while configuring httpd for HTTP/2 the first time, so please keep it in mind to avoid
long debugging sessions! If you want to be sure about the cipher suite to choose please avoid
the ones listed in the HTTP/2 TLS reject list (
makes the order you wrote the Protocols irrelevant and only the client's ordering will decide.
@@ -225,12 +226,12 @@ ProtocolsHonorOrder OffThe first tool to mention is of course curl. Please make sure that
your version supports HTTP/2 checking its Features:
Homebrew's curl includes HTTP/2 support by default. Install with
@@ -277,33 +278,33 @@ ProtocolsHonorOrder Off
Link headers
in a certain format:
If the connection supports PUSH, these two resources will be sent to the client. As a web developer, you may set these headers either directly in your application response or you configure the server via
If you want to use preload links without triggering a PUSH, you
can use the nopush parameter, as in
or you may disable PUSHes for your server entirely with the directive
And there is more:
The module will keep a diary of what has been PUSHed for each connection @@ -320,13 +321,13 @@ H2Push Off PUSH might not always trigger the request/response/performance that one expects or hopes for. There are various studies on this topic to be found on the web that explain benefits and weaknesses and how different features of client and network influence - the outcome. For example: just because the server PUSHes a resource does not mean + the outcome. For example: the fact that the server PUSHes a resource does not mean a browser will actually use the data.
The major thing that influences the response being PUSHed is the request that was
simulated. The request URL for a PUSH is given by the application, but where do the
request headers come from? For example, will the PUSH request a accept-language
header and if yes with what value?
Apache will look at the original request (the one that triggered the PUSH) and copy the +
httpd will look at the original request (the one that triggered the PUSH) and copy the
following headers over to PUSH requests: user-agent, accept,
accept-encoding, accept-language, cache-control.
All other headers are ignored. Cookies will also not be copied over. PUSHing resources @@ -340,22 +341,22 @@ H2Push Off
An alternative to PUSHing resources is to send Link headers to the
client before the response is even ready. This uses the HTTP feature called "Early Hints" and
is described in
In order to use this, you need to explicitly enable it on the server via
+To use this, you need to explicitly enable it on the server via
(It is not enabled by default since some older browser tripped on such responses.)
If this feature is on, you can use the directive
This will send out a "103 Early Hints" response to a client as soon
as the server starts processing the request. This may be much earlier than