HTTP 2.0 has been around since 2015, but many developers working with REST-APIs haven´t learned about it yet. A real shame, because you can now do a lot more with it!
Most browsers started supporting it immediately.
As the flexibility of the data transfer has been improved, new different sending methods possibilities have been developed. Probably frontend developer catched this. But most backend developers are not fully aware of it I think.
In HTTP 2.0 a new approach has come to life through the introduction of a binary framing layer. The requests are no longer sent as plain text. The messages are encapsulated in binary format, decomposed into smaller packets.
Multiple streams of data, consisting of multiple request/response messages that are now splitted in smaller units (frames), make use of the same TCP connection, by being interleaved and then reassembled at destination.
The use of one single TCP connection allows to reduce the resources required for the transmission.
A stream priorization mechanism has been introduced to tackle the performance issues due to several streams waiting for the same resource .
If you are developer you can take advantage of it, by setting the weights in your requests based on your rendering and user interactions needs. For instance, large image loading might have a low priority.
While previously resources (like images) and html pages where sent separetely, you can now send them together before the client requests them. This mechanism is called “server push” and enables to fix the major drawback of resource inlining. The client can then decide wheter to cache or decline the resource pushed along with the HTML document.
Although the client may have not requested the resources yet, with the server push mechanism introduced in HTTP 2.0 you can send cacheable resources along with the HTML content anyway and even prioritize them (stream prioritization).
The client can choose to:
- cache the pushed resources and then reuse them for faster navigation
- limit the amount of concurrent pushed streams
- deactivate the resource pushing completely.
With the server push you can spare a significant amout of loading time. Even seconds.
However, since header messages (including cookies) hadn´t been compressed before HTTP 2.0 came out, bottleneck issues have always been a problem.
For this reason with HTTP 2 the headers compression has been introduced, by using HPACK, a tool developed on purpose.
For more information check: