HTTP is the web’s application-layer protocol.

HTTP uses TCP

  • client initiates TCP connection
  • server accepts TCP connection from client
  • HTTP messages are exchanged between the server and the client, and then the connection is closed
  • HTTP is stateless, the protocol does not require the server to maintain information about past client requests
  • No need for client/server to recover from partially-completed-but-never-completely-completed transactions
  • All HTTP requests are independent of each other

Non-persistent HTTP

  • TCP connection is opened
  • One object (one request and one response) is sent over the connection
  • TCP connection is closed

Persistent HTTP

  • TCP connection is openned to a server
  • Multiple objects can be sent over a single TCP connection and that server
  • TCP connection closed

Persistent HTTP, was introduced in HTTP1.1 and can reduce RTT as it does not require 2 RTTs per object, it also reduces OS overhead for each TCP connection

Example HTTP message

GET /foo/bar.idk HTTP/1.1
Host: foo.bar

Maintaining state

Whilst the protocol itself is stateless, HTTP servers often need to keep track of connections.

As such, cookies can be used.

Maintaining Cookies

  • Cookie header line of HTTP response
  • Cookie header line in next HTTP request message
  • Cookie file kept on user’s host managed by the browser
  • back-end database on the server

Cookies can also be used to track user behaviour on a given website or across multiple websites with third party cookies.

The tracking may be invisible to the user, third party cookies in modern browsers are typically restricted for this reason

Web Caches

A user can configure a browser to point to a local web cache, all HTTP requests can be forwarded to the cache and if the object is in the cache, the cache returns the object to the client, otherwise the object is fetched, cached and then returned.

A web cache acts as both a client and server.

Cache-Control

The Cache-Control header can be used to tell the cache about an object’s allowable cache behaviour:

Cache-Control: max-age-<seconds>
Cache-Control: no-cache

Web caching is useful as it can reduce traffic on the upstream server and reduce response time for client requests

Browser Cachine

Browsers can send a conditional get request via the if-modified-since header.
If the content has not changed, the server can respond with HTTP/1.0 304 Not Modified.

HTTP/2

The goal of HTTP/2 was to decrease the delay in multi-object HTTP requests

  • HTTP1.1 introduced pipelined GETs over a single connection
  • Responses in FCFS order
  • HTTP/2 allows transmission order to be based on client-specified object priority, not FCFS
  • HTTP/2 servers can push unrequested objects to the client - MODERN BROWSERS NO LONGER SUPPORT THIS
  • HTTP/2 allows objects to be divided into frames which can be scheduled to mitigate HOL blocking

HTTP/3

  • HTTP/2 over a single connection still means packet loss can stall all object transmissions
  • No security as it’s over a vanilla TCP connection
  • HTTP/3 improves this massively through the use of security, per-object error control, congestion control, pipelining, and runs over UDP

E-mail

User Agent

  • The “mail reader”
  • Handles composing, editing and reading mail messages

Mail Servers

  • Mailbox contains incoming messages for the user
  • Message queue of outgoing messages

The SMTP protocol is used between mail servers to send messages

  • SMTP handles delivery/storage of email mesages to the reciever’s sender
  • IMAP allows messages to be stored on the server, provides retrieval, deletion, folders of stored messages on the server
  • HTTP is often used for web-based email interfaces