The OSI model / TCP/IP model

notion image


HTTP persistent connections, also known as HTTP keep-alive or HTTP connection reuse, allow for multiple requests and responses over a single connection.
To solve the issue of having to wait for the previous response before sending the next request, HTTP pipeline is introduced.
Since HTTP is stateless, cookies are used to maintain state. When the server sends a Set-Cookie header, the client saves the cookie. The next time the client sends a request to the server, it automatically includes the cookie.
HTTP also provides a resuming mechanism to recover from an endpoint using Range.
GET /tip.jpg HTTP/1.1
Host: www.example.com
Range: bytes =-3000, 5000-7000
It will return 206 Partial Content Response.
HTTP/1.1 introduced a 'persistent connection' feature that allowed TCP connections to be reused. However, it did not address the issue of 'Head-of-Line' (HOL) blocking, which happens when all request slots in a browser are full, causing subsequent requests to wait for previous ones to finish.
HTTP/2.0 solved the HOL blocking issue by introducing HTTP streams, which enabled multiple HTTP exchanges to be sent concurrently on the same TCP connection. However, HOL blocking could still occur at the TCP layer.
HTTP/3.0 replaces TCP with QUIC as the underlying transport protocol. This eliminates HOL blocking at the transport layer. QUIC is based on UDP and introduces streams as first-class citizens. QUIC streams share the same connection, and are delivered independently, preventing packet loss in one stream from impacting others.

Content Negatiation

Server-driven Negotiation
The server is doing the content negatiation, and handing it in server depend on the information sent by the browser.
Agent-driven Negotiation
User select from the possible options on website.
Transparent Negotiation
Combine the Server-driven Negotiation and Agent-driven Negotiation
A physical machine may have multiple virtual hosts. When the server receives a request, it identifies the IP address. To determine which website is being requested, the "Host" field in the header must contain the hostname or domain name URI. The Host is a required field.
It will help specific the langaguge shows to the user if a website has different versions of language.
  • Accept
  • Accept-Charset
  • Accept-Encoding
  • Accept-Language
  • Content-Language
Max-Forwards can help us limit the number of proxies or gateways that can forward the request. When a request is forwarded, the value of Max-Forwards is decremented by one. If the value reaches zero, the request is rejected. If the http proxy reqtest failed
Transparent Proxy is the server that doesn’t process the contents.
no-cache and no-store are both used to prevent caching. However, no-cache allows the response to be cached, but requires validation with the server before serving a cached copy, while no-store strictly prohibits caching of the response. This means that with no-store, the response must be re-requested from the server each time it is needed.
Comet is an old technique for server push updates to a web page. It involves holding a connection open between the client and server, and sending updates over this connection as they become available. However, this technique has been replaced by WebSockets and server push, which are more efficient and reliable ways to achieve real-time updates.
SPDY was an experimental protocol for the web with the primary goal to reduce latency of web pages. Its successor is HTTP/2.
WebSocket is a computer communication protocol that enables full-duplex communication channels over a single TCP connection. To initiate the connection, WebSocket uses HTTP for the handshake. Once the handshake is complete, WebSocket is used for communication.


DNS resolver
Initiates querying sequence and forwards requests to other DNS name servers
Root-level name servers
Maintain name servers based on top-level domain names (.com, .edu, .us, etc.)
Top-level domain (TLD) name servers
Hold the IP addresses of authoritative name servers
Authoritative name servers
Provide IP addresses of web or application servers for the organization.
What is DNS? What is it used for?
DNS (Domain Name System) is a protocol used to convert domain names into IP addresses. Computer networking (at layer 3 of the OSI model) is done with IP addresses, but as humans, it can be difficult to remember IP addresses. It's much easier to remember domain names. This is why we need something like DNS to convert any domain name we type into an IP address. You can think of DNS as a large phone book or database where each name corresponds to an IP address.
What is DNS resolution?
The process of translating IP addresses to domain names.
What is name server?
A server which is responsible for resolving DNS queries.
What is the resolution sequence of: www.site.com
It's resolved in this order:
  1. .
  1. .com
  1. site.com
  1. www.site.com
What is a domain name registrar?
According to Cloudflare, a domain name registrar is a provider of domain name registrations to the general public. It is a common misconception that registrars sell domain names; in fact, the domain names are owned by registries and can only be leased by users.
Root of www.blipblop.com
Top level domain of www.blipblop.com
Second level domain of www.blipblop.com
Domain of www.blipblop.com
High-Level Description of DNS Resolution Workflow
In general, the DNS resolution process is as follows:
  1. The user types an address in the web browser (e.g. some_site.com)
  1. The operating system sends a request to the browser to translate the address the user entered
  1. A query is created to check if a local entry of the address exists in the system. If it doesn't, the request is forwarded to the DNS resolver
  1. The DNS resolver, usually configured by your ISP when you connect to the internet, is responsible for resolving your query by contacting other DNS servers
  1. The resolver contacts the root nameserver (also known as ".")
  1. The root nameserver either responds with the address you are looking for or it responds with the address of the relevant Top Level Domain (TLD) DNS server (e.g. if your address ends with ".org", then the ".org" TLD)
  1. The resolver then contacts the TLD DNS. The TLD DNS might respond with the address you are looking for. If it doesn't have the information, it will provide the address of the Second Level Domain (SLD) DNS server
  1. The SLD DNS server will reply with the address to the resolver
  1. The resolver passes this information to the browser, while your OS also stores this information in the cache
  1. The user can browse the website with happiness and joy :D
What is a DNS record?
A mapping between domain name and an IP address. What types of DNS records are there? • A • PTR • MX • AAAA ... A more detailed list, can be found here
What happens if a network is congested? Should DNS continue using UDP?
DNS typically uses UDP. However, when a DNS message exceeds the original packet size of 512 bytes, DNS can use TCP instead. This is because large packets are more prone to damage in congested networks. DNS always uses TCP for zone transfers.
To ensure privacy, some clients prefer DNS over TCP to employ transport layer security.
Record Type
Maps a host name to an IPv4 address
maps example.com to
Performs the same function as A record, but for an IPv6 address
maps example.com to 2001:0db8:85a3:0000:0000:8a2e:0370:7334
Maps a hostname to another hostname, acts as an alias
maps www.example.com to example.com
Resolves the IP address to a domain name
maps to example.com
Specifies the mail exchange server for the domain, allows mail delivery
maps example.com to mail.example.com
Specifies name servers that can respond to DNS queries
maps example.com to ns1.example.com, ns2.example.com
DNS Record TTL
According to varonis.com, "DNS TTL (time to live) is a setting that tells the DNS resolver how long to cache a query before requesting a new one. The information gathered is then stored in the cache of the recursive or local resolver for the TTL before it reaches back out to collect new, updated details."
Does DNS use TCP or UDP?
DNS uses UDP port 53 to resolve queries, both regular and reverse. DNS uses TCP for zone transfer.
If we need DNS to tell us which IP to reach a website or service, how will we know the DNS resolver’s IP address? (It seems like a chicken-and-egg problem!)
End users' operating systems contain configuration files, such as /etc/resolv.conf in Linux, that specify the IP addresses of DNS resolvers. These resolvers, in turn, obtain all necessary information for DNS queries. DHCP often provides the default DNS resolver IP address and other configurations. When end-systems make DNS queries, they request DNS resolution from these resolvers, which have special software installed to resolve queries through the DNS infrastructure. The IP addresses of root servers are included in this special software. DNS resolvers typically use the Berkeley Internet Name Domain (BIND) software. The InterNIC maintains an updated list of the 13 root servers.
To address the chicken-and-egg problem, each resolver is seeded with prior knowledge of the root DNS servers, whose IP addresses rarely change. This breaks the cycle of dependency between DNS resolvers and root servers.
HTTP Keep-Alive vs TCP keepalive
HTTP Keep-Alive maintains the TCP connection until either party requests disconnection.
HTTP Keep-Alive reduces TCP connection overhead. When combined with HTTP/2 and streams, we can send multiple requests simultaneously and handle them out of order.
Usually in http1.1, we wait for a response before sending another request. But with HTTP/2 streams, we can send many requests at once without waiting for a response, and the server can respond in any order.