Previously we published guide on how to enable HTTP/2 on Apache, of course we published other guides like cache aware server push. mod_http2 Enables HTTP/2, has settings which are usually kept as default. In this guide we will talk around the possibilities to tweak Apache HTTP/2 settings aka optimise module mod_http2. mod_http2 module relies on libnghttp2 to provide the core http/2 engine and present is experimental. It is very important to understand that the directives can change behaviours from default which may not be suitable to test on a production server hosting serious live website.
Apache HTTP/2 Settings : Optimize Module mod_http2
The first directive is known, it is used to activate HTTP/2 and used with mod_ssl block and virtual server block :
Protocols h2 http/1.1
The above settings make http/1.1 as first option, http/2 as second option. The below settings will work on server configuration file unless otherwise specified, some works on virtual host file as well.
HTTP/2 has a Direct Mode, and can be made on or off with :
Default settings is ON. Maximum number of active streams per HTTP/2 session can be adjusted with :
Default is 100. You can lower down to 50 or even 20. Obviously, the maximum number of seconds http/2 workers will remain idle until shut down that can be changed too :
600 is default value, you can change to lower value like 20. We can change the maximum and minimum number of worker threads to use per child process :
There is a security and cipher related settings to toggle security checks on HTTP/2 connections in TLS mode, which is by default kept to off and safe to keep to off :
We can toggle HTTP/2 push on or off, default is on :
There is a H2PushPriority directive, which is important to force before or after, select type of thing :
H2PushPriority * After 16
H2PushPriority text/css Interleaved 256
H2PushPriority application/json Before
H2PushPriority application/json 32
H2PushPriority image/jpeg before
H2PushPriority text/css interleaved
The directives to serialise HTTP/2 requests usually not good for performance (it falls back to http/1.1) :
We can set the maximum number of outgoing data bytes buffered in memory for an active streams with this directive :
Above is default value, you can change to higher value like
We have warm up and cool down directive :
The above warm up and cool down directives are what Google’s peoples say TLS record optimisation in context of Nginx.
We can control toggle of the usage of the HTTP/1.1 upgrade method for switching to HTTP/2 :
We can set the size of the window for flow control from client to server to limit the amount of data the server has to buffer. This affects only request bodies :
These are what officially known.