How to enable HTTP/2 on the Apache web server
To enable HTTP/2 in Apache, you will need to meet the following
requirements:
First, you need to enable HTTPS on your server. All major browsers allow the use of HTTP/2 by HTTPS only. In addition, the TLS>= 1.2 protocol version with modern encryption sets is required.
Then make sure you’re running Apache 2.4.17 or higher, as HTTP/2 is supported from this release and up.
Also, make sure your client/browser actually supports HTTP/2.
Enable HTTP/2 support in Apache
In order for HTTP/2 to work in Apache, it is necessary to enable and load the SSL and HTTP/2 modules. To do this, you can run the following on your terminal:
sudo a2enmod ssl
and then
sudo a2enmod http2
To activate these new modules, you need to run:
sudo systemctl restart apache2
After enabling and loading the required Apache modules, navigate to the Apache configuration directory and edit the Apache configuration.
To enable HTTP/2 on your Apache web server, include one of the following items in your global Apache configuration or within a specific virtual host.
Protocols h2 http/1.1
Here is the minimum virtual server configuration that can be used to enable HTTP/2 on some virtual host:
<VirtualHost *:443>
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/public_html/example.com
SSLEngine on
SSLCertificateKeyFile /path/to/private.pem
SSLCertificateFile /path/to/cert.pem
SSLProtocol all -SSLv3 -TLSv1 -TLSv1.1
Protocols h2 http/1.1
</VirtualHost>
To check if your server supports HTTP/2, you can use your browser development tools. See below screenshots of Google Chrome and Apple Safari browsers that show HTTP/2 in action in the domain https://example.com .
To test if HTTP/2 is working Visit this site https://tools.keycdn.com/http2-test
enter the desired domain.
See below the ex:
Since the syntax is the same as version 1.1, it will not influence the language
used, right?
Yeah, yeah, yeah:
- These are the high-level differences between HTTP1 and HTTP2:
- HTTP2 is binary instead of textual
- HTTP2 is fully multiplexed instead of ordered and blocked
- HTTP2 can therefore use a connection for parallelism
- HTP2 uses header compression to reduce overhead
- HTTP2 allows servers to "push" responses proactively to client caches
HTTP/2 does not modify the application’s HTTP semantics in any way. All key concepts, such as HTTP methods, status codes, Uris and header fields, remain the same. In fact, HTTP/2 modifies how data is formatted (in frames) and transported between the client and the server, which manage the entire process, and hides all the complexity of the applications within the new frame layer. Thus, all existing applications can be provided without modification...
In HTTP 2.0 and SPDY, there is a better solution, called server-push. The idea is that the server can send some resources to the browser without even having requested it yet. Imagine the browser requesting index.html and the server already responding to index.html, style.css, some icons etc. The server pushes resources into the browser that it knows would be requested right away. With this, when the browser needs the resource, it will already be cached and will not need to make a request.
Version 1.1 will be maintained in parallel to 2 to support
older browsers?
Yes, but with time it is natural that you will migrate to HTTP/2
Reference:
https://www.howtoforge.com/how-to-enable-http-2-in-apache/
https://www.greenlanemarketing.com/blog/seo-101-http-vs-http2/
https://developers.google.com/web/fundamentals/performance/http2/? hl=en
https://blog.caelum.com.br/as-fantasticas-novidades-do-http-2-0-e-do-spdy/
Take a look at http2 explained, in Portuguese. There is a lot of enlightening material, mainly in English. To its purpose, https://httpd.apache.org/docs/2.4/howto/http2.html ;)
– jcbrtl