? my $ctx = $main::context; ? $_mt->wrapper_file("wrapper.mt", "Configure", "HTTP/2 Directives")->(sub {

H2O provides one of the world's most sophisticated HTTP/2 protocol implementation, including following features.

Prioritization

H2O is one of the few servers that fully implement prioritization of HTTP responses conformant to what is defined in the HTTP/2 specification. The server implements a O(1) scheduler that determines which HTTP response should be sent to the client, per every 16KB chunk.

Unfortunately, some web browsers fail to specify response priorities that lead to best end-user experience. H2O is capable of detecting such web browsers, and if it does, uses server-driven prioritization; i.e. send responses with certain MIME-types before others.

It is possible to tune or turn off server-driven prioritization using directives: file.mime.addtypes, http2-reprioritize-blocking-assets.

See also:

Server push

H2O recognizes link headers with preload keyword sent by a backend application server (reverse proxy or FastCGI) or an mruby handler, and pushes the designated resource to a client.

{example}->('A link response header triggering HTTP/2 push', <<'EOT') link: ; rel=preload; as=script EOT ?>

When the HTTP/2 driver of H2O recognizes a link response header with rel=preload attribute set, and if all of the following conditions are met, the specified resource is pushed to the client.

The server also provides a mechanism to track the clients' cache state via cookies, and to push the resources specified with the link header only when it does not exist within the clients' cache. For details, please refer to the documentation of http2-casper configuration directive.

When a resource is pushed, the priority is determined using the priority attribute of the MIME-type configuration. If the priority is set to highest then the resource will be sent to the client before anything else; otherwise the resource will be sent to client after the main content, as per defined by the HTTP/2 specification.

HTTP/1.1 allows a server to send an informational response (see RFC 7230 section 6.2) before sending the final response. Starting from version 2.1, web applications can take advantage of the informational response to initiate HTTP/2 pushes before starting to process the request. The following example shows how such responses would look like.

{example}->('100 response with link headers', <<'EOT') HTTP/1.1 100 Continue Link: ; rel=preload; as=style Link: ; rel=preload; as=script HTTP/1.1 200 OK Content-Type: text/html; charset=utf-8