What is HTTP2 and Why to use HTTP2 for your website and servers?
HTTP/2 is the latest update to the HTTP protocol by the Internet Engineering Task Force (IETF)
HTTP/2, the successor of HTTP1.x.
HTTP2 has been widely growing in popularity due to many of its performance benefits. As webpage sizes are growing and becoming more resource-intensive, it is vital to stay current with performance optimization techniques and strategies.
Why HTTP2 rather then HTTP1?
HTTP/2 can send multiple requests for data in parallel over a single TCP connection. This is the most advanced feature of the HTTP/2 protocol because it allows you to download web files asynchronously from one server. Most modern browsers limit TCP connections to one server.
Multiple requests are allowed at the same time, on the same connection. Previously, with HTTP/1.1, each transfer would have to wait for other transfers to complete.
Earlier HTTP1 used to process text commands to complete requests. But HTTP2 is binary based that means (in 1s and 0s) to executes the same command.
Header Compression (HPACK)
HTTP2 compresses header which reduces overheads.
Suppose once a client connected or used any server in past then HTTP2 uses that header information and reduces sending header with every request. As compared to HTTP1 many headers were send with every request.
Watch performance difference between HTTP1 and HTTP2
How to enable HTTP2 in Nginx server?
Now let’s activate HTTP2 for your websites and apps to improve performance.
[email protected]:~$ vim /etc/nginx/nginx.conf listen 443 ssl; to listen 443 ssl http2; [email protected]:~$ nginx -t [email protected]:~$ systemctl restart nginx