HTTP2 and SPDY Protocols - Make HTTP Faster and Safer

Reading Time : ~ .

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:
    1. Compression.
        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.

    2. Prefetching:
        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.

    3. Priority:
        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

Finally replace:
    listen 443 ssl;
        with
    listen 443 ssl http2;
Reload Nginx.

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.
~

    By Posted On
SENIOR DEVELOPER at MICROPYRAMID

Need any Help in your Project?Let's Talk

Latest Comments
Related Articles
Django hosting on Nginx with uwsgi for high performance Ashwin Kumar

Quick guide to host django application using uwsgi and nginx which offers better resource utilization and performance.

Continue Reading...
Setting Up Sentry - Web Application Event Tracking platform Jagadeesh V

When you want to track your exception and log mesages in a UI rather than storing it in a file(which we usually do), we can ...

Continue Reading...
Securing Elastic search Instance with Shield Jagadeesh V

Shield allows you to protect elastic search data with a username and password. It provides additional functionalities like encryption, role-based access control, IP filtering. It ...

Continue Reading...

Subscribe To our news letter

Subscribe to our news letter to receive latest blog posts into your inbox. Please fill your email address in the below form.
*We don't provide your email contact details to any third parties