HTTP2 and SPDY Protocols - Make HTTP Faster and Safer2022-07-25
HTTP/2, next version of HTTP/1, http/1 can not handle the present web which has become more resource intensive, it cannot processes multiple requests in an efficient manner. HTTP/2 has got many techniques to harness the requirements of current web experience.
SPDY is the core part of HTTP/2 protocol, many of the http/2 protocol techniques are part SPDY.
SPDY(speedy) is a network protocol which manipulates http protocol by compressing headers, predicting clients requests(example discussed below) and other techniques, to fasten web experience.
SPDY was developed by Google. However in favour of http/2 which makes use of SPDY techniques, SPDY is deprecated. So until you are with http/1, SPDY will boost your website speed, Google says, speedy(SPDY) boosts website speed upto 55%.
SPDY supports all major browsers(firefox, chrome, opera, safari, ie).
Why speedy is fast:
Speedy compresses the headers, it will track whether the headers in this particular session has been sent and if sending headers was has already done then it is of no use to resend untilsession expires.
If a client requests for an html file which includes some links(css stylesheets) then in http/1 protocols, the client should have to send request for getting those links(css stylesheets). In this case a speedy server could parse the html, include those links and send without waiting for client to ask for links.
HTTP/1 handles limited parallel connections, like 6-8 based on browser, if connections are more, then we have to wait until previous connections are resolved, so even if there are connections that are important we have to wait. Speedy workarounds by using prioritized streams, so most urgent requests will be resolved first.
4. Most importantly multiplexing
As said above about limited parallell connections, multiplexing can solve this, multiplexing basically means combining many signals into one, so the speedy browser combines its many requests into a single request and sends to server, the server then divides the requests(demultiplexing) into original number of requsts and responds.
Speedy is fast because extra work is done by both client and server for processing the above tasks.
Although http/2 has speedy at its core, http/2 can handle multi-host multiplexing, has faster encryption, has faster compression rate.
HTTP/2 for Nginx:
Nginx started support for http/2 from version 1.9.5, so if you are using Long term support OS version like Ubuntu 14.04 then you should add latest nginx deb repo to source list before installing nginx.
Follow the following commands if you have nginx version below 1.9.5
wget -O - http://nginx.org/keys/nginx_signing.key | sudo apt-key add - echo "deb http://nginx.org/packages/mainline/ubuntu/ trusty nginx" | sudo tee -a /etc/apt/sources.list echo "deb-src http://nginx.org/packages/mainline/ubuntu/ trusty nginx" | sudo tee -a /etc/apt/sources.list sudo apt-get update sudo apt-get install nginx
listen 443 ssl;
listen 443 ssl http2;
Thats it.... you are ready to go.
To check http2 is on, visit: https://tools.keycdn.com/http2-test or checkout chrome sniffer extension, displays details of site, whether using nginx, jquery, disqus etc..It will show spdy if http2 or spdy protocol are enabled.