Day 4 of #30DaysOfWebPerf - As we continue to explore ways to improve site speed by improving image delivery๐, let us look into one very popular method of doing so - Domain Sharding. We will also explore the benefits of HTTP2 and see how these 2 play together #webperf #webdev19:14 PM - 29 Nov 2019
What is domain sharding? You may already know this, but browsers have a limit on concurrent connections for each hostname. Domain sharding is a method used to increase the number of simultaneously downloaded resources for a website. Images from etondigital.com/domain-shardinโฆ19:14 PM - 29 Nov 2019
1 other benefit you get out of domain sharding is being able to deliver images, CSS and JS files from a ๐ช-less domain. This reduces the size of the response headers drastically as there are no cookies sent over the wire. This technique has proven to improve performance ~30%.19:14 PM - 29 Nov 2019
Some sites that are successfully using domain sharding include @Macys, @Flipkart, @Rakuten, @BestBuy, @Bloomingdales and many more... In the example from Macy's mobile homepage, you will notice that they are leveraging the benefits of both domain sharding and a ๐ช-less domain.19:28 PM - 29 Nov 2019
Domain sharding does increase the time for DNS lookup to the new domain. However, this can be mitigated with preconnect. Preconnect allows the browser to set up early connections before an HTTP request is actually sent to the server.
<link href='' rel='preconnect' crossorigin>19:28 PM - 29 Nov 2019
Domain sharding definitely seems to be promising, but then is it relevant today when we have HTTP2? Funny you should ask. Let's first see what value HTTP2 gets to the table. This article - developers.google.com/web/fundamentaโฆ details everything you need to know about #HTTP2 #webdev #webperf19:50 PM - 29 Nov 2019
One of the major benefits that #http2 gets to the table is multiplexing which is what we were achieving with domain sharding in http1.1. Then do we need domain sharding anymore? This article helps you understand the benefits of HTTP2 -medium.com/@jacobtan/undeโฆ19:50 PM - 29 Nov 2019
This leaves us with the Cookies being sent as part of the headers. #http2 solves this for you as well with header compression using #hpack HTTP/2 uses an index table, which stores the headers received from the first request it handles. #optimization #webperf #webdeveloper19:50 PM - 29 Nov 2019
Subsequent requests then only have to send the index of the duplicate header, opposed to the full textual value. Unique headers or headers that have changed are sent as normal. #optimization #http2 #webperf #30daysofwebperf19:50 PM - 29 Nov 2019
So now the million dollar question - Do we need #DomainSharding with #http2? Most likely NOT. If you have HTTP2 enabled correctly for your domain on the CDN/server, you will get all the performance enhancements of domain sharding without breaking a sweat๐ #perfnow20:23 PM - 29 Nov 2019
That's a wrap for day 4 of #30DaysOfWebPerf If you do not have #http2 enabled go do it now! It will be absolutely worth it. To learn more about #webperf and share your thoughts on it, continue to follow me here on #Twitter or on @ThePracticalDev at dev.to/shreerangp/30dโฆ ๐ฆ20:23 PM - 29 Nov 2019
Top comments (0)