The web has changed dramatically over the last decade, yet the backbone of the web – HTTP, hasn’t been changed. HTTP/1.1 has got various limitations and web developers have always worked around those,
- Performance issue in terms of bandwidth utilization
- Performance issue in terms of resource consumption in client and server
- Web design and maintenance are complex
HTTP/2 tries to solve many shortcomings of HTTP/1.1. It’s main benefits are Multiplexing and concurrency, header compression, server push.
Migration path from HTTP/1.1 to HTTP/2 should be relatively simple, the application and API should continue to work uninterrupted with better performance and consume fewer resources in client and server.
Because HTTP/2 already comes with so many benefits, the workarounds which web developers have been using to achieve similar benefits, become anti-patterns and may cause sub-optimization. If you or your organization is thinking about fully capitalizing on HTTP/2, it is highly recommended to follow few best practices:
- Avoid the anti-patterns
- Image Spriting – image sprite is a collection of images put into a single image
- Inlining Images – Inline image uses data URI to embed image items. Inline images saves HTTP requests over externally referenced objects. Refer link for more details
- Domain Sharding – Domain sharding splits resources across subdomains to improve performance. Allow simultaneous resource download at any given time.
- Some best practices are still best practices
- Reduce DNS lookups – DNS queries could be expensive, especially if you have to start your query at the root nameserver. DNS prefetching via a link rel=’dns-prefetch’ href=’…’ /> line in your document’s head> can help.
- Continue to use Content Delivery Network – put your web assets geographically closer to your visitors
- Leverage on browser cache – This reduce network traffic. Sometime there are 304 Not modified response happens
- Minimize size of HTTP request – Even though HTTP/2 multiplex request, it still takes time to transfer data. So minimize the data size like query string, etc.
- Reduce and eliminate unnecessary redirects – Redirect cause unnecessary roundtrip between the browser and the server which in turn adds latency. But sometimes when we redesign or migrate the application, we got to implement few unavoidable redirects, that’s life.
Categorized in: Web Development
This post was written by hackya