HTTP and Websockets: Understanding the capabilities of today’s web communication technologies

Deciding what to choose for your next web API design

Thilina Ashen Gamage
Platform Engineer

--

There are so many classifications for APIs. But when it comes to web communication, we can identify two significant API types — Web Service APIs (e.g. SOAP, JSON-RPC, XML-RPC, REST) and Websocket APIs. But, what do these really mean? Let’s dive into the world of web communication protocols and discuss how to choose the best API mechanisms at the end.

HTTP

HTTP is the underlying communication protocol of the World Wide Web. HTTP functions as a request-response protocol in the client-server computing model. HTTP/1.1 is the most common version of HTTP used in modern web browsers and servers. In comparison to early versions of HTTP, this version could implement critical performance optimizations and feature enhancements such as persistent and pipelined connections, chunked transfers, new header fields in request/response body etc. Among them, the following two headers are very notable, because most of the modern improvements to HTTP rely on these two headers.

  • Keep-Alive header to set policies for long-lived communications between hosts (timeout period and maximum request count to handle per connection)
  • Upgrade header to switch the connection to an enhanced protocol mode such as HTTP/2.0 (h2,h2c) or Websockets (websocket)

--

--

Thilina Ashen Gamage
Platform Engineer

Advocate of Cloud, Microservices, & Clean Code | 1.5M+ Reach | For more exciting content, stay in touch: https://medium.com/@ThilinaAshenGamage