Skip to content

Latest commit

 

History

History
35 lines (29 loc) · 1.83 KB

how-the-web-works.md

File metadata and controls

35 lines (29 loc) · 1.83 KB

How the Web Works

  1. IP address needed
  • DNS resolution chain: browser cache >> local HOSTS file >> Router's DNS >> ISPs DNS
  • Network stack uses ARP to find its configured DNS server if address not cached
  • IP address is found for hostname google.com
  1. Browser asks OS to open a TCP connection to the resolved IP address
  • With an IP address, typical TCP connection flow follows:
    • OS calls the network stack to search for the next hop using a SYN request
    • SYNs and ACKs are traded between network nodes until the destination sever is reached
    • Path to host is now known
  • Server responds that it's ready to receive data
  • OS/Browser receives signal that the server is ready to receive data
  1. HTTP protocol is started; GET request sent
  • Requests can contain headers (cookies, user-agents, tokens, query params)
  • If Request is POST, it can contain a Payload in addition to Headers
  1. Server receives GET through the TCP/IP protocol
  • OS routes packet coming in on port 80 to a Web Server that's listening on port 80
  • Web Server routes request to some middleware
  • Middleware parses incoming string into Headers and Payloads and hands off to a Web Application Server
  • Web App routes incoming request to appropriate action based on the Method and Action used (GET /dogs)
  • Web App server generates a Response based on input
  • Server responds to Request by sending back a Response
  1. Browser receives Response (big string)
  • Response/String is parsed into Response Headers and a Payload
  • Headers are read; cookies stored, etc
  • Browser parses the Payload (HTML)
  • If HTML contains links to other resources (.js, css, images) the process starts all over again
  1. Browser renders the parsed Response's payload
  • The load event is fired when a resource and its dependent resources have finished loading