Couple of months ago, HTTP/2 was published as RFC7540.
How will this affect the existing REST API built on HTTP/1.1?
As per Wikipedia, HTTP/2 has added new features.
How can we take advantage of these new features?
This means that REST APIs built on HTTP/1.1 will continue to work transparently as before, with no changes to be made to applications.
To speed up web performance, both HTTP/1.1 and HTTP/2 compress HTTP messages to make them smaller. However, HTTP/2 uses a more advanced compression method called HPACK that eliminates redundant information in HTTP header packets. This eliminates a few bytes from every HTTP packet.
gRPC heavily uses HTTP/2 features and no browser provides the level of control required over web requests to support a gRPC client. For example, browsers do not allow a caller to require that HTTP/2 be used, or provide access to underlying HTTP/2 frames.
The main semantic of HTTP has been retained in HTTP/2. This means that it still has HTTP methods
such as GET
, POST
, etc., HTTP headers
, and URIs
to identify resources.
What has changed in HTTP/2 with respect to HTTP/1.1 is the way the HTTP semantic (e.g. "I want to PUT
resource /foo
on host domain.com
") is transported over the wire.
In this light, REST APIs built on HTTP/1.1 will continue to work transparently as before, with no changes to be made to applications. The web container that runs the applications will take care of translating the new wire format into the usual HTTP semantic on behalf of the applications, and application just see the higher level HTTP semantic, no matter if it was transported via HTTP/1.1 or HTTP/2 over the wire.
Because the HTTP/2 wire format is more efficient (in particular due to multiplexing and compression), REST APIs on top of HTTP/2 will also benefit of this.
The other major improvement present in HTTP/2, HTTP/2 Push
, targets efficient download of correlated resources, and it's probably not useful in the REST usecase.
A typical requirement of HTTP/2 is to be deployed over TLS. This require deployers to move from http
to https
, and setup the required infrastructure to support that (buy the certificates from a trusted authority, renew them, etc.).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With