What happens when a browser requests a web page like example.com?

  1. you enter example.com
  2. your browser will do a DNS look up for the IP address of this URL. This process is:
    1. check browser cache – the OS does not tell the browser the TTL for each DNS record so the browser caches DNS records itself for 2 – 30 minutes
    2. check OS cache – e.g. gethostbyname on the Mac and Windows
    3. check router cache
    4. check ISP DNS cache
    5. recursive search
      1. root nameserver
      2. .com nameserver
      3. example.com nameserver
  3. browser sends a GET HTTP request to the web server along with other headers. e.g.
    1. Host: example.com
    2. Accept: types of responses it will accept
    3. Connection: TCP connection
    4. Cookie:
  4.  server probably responds with a 301 Permanent redirect to www.example.com
  5. browser sends out another request to www.example.com
  6.  server handles the request
    1. i.e. it reads the request, any parameters and cookies
  7. server sends back an HTML response which consists of
    1. HTTP/1.1 200 OK header
    2. Cache-Control:
    3. Expires:
    4. Pragma:
    5. Content-Encoding: gzip
    6. Content-Type: text/html; charset=utf-8
    7. Date:
    8. Byte blob which the Content-Encoding section tells you is gzip’d.
    9. Decompress the blob to get the HTML
  8. Browser renders the HTML as it starts receiving it
  9. Browser sends requests for objects embedded in the HTML. E.g.
    1. images
    2. CSS
    3. JS
  10. Browser sends further AJAX

See  Hypertext Transfer Protocol — HTTP/1.1 (RFC 2616): https://tools.ietf.org/html/rfc2616

Leave a Reply

Your email address will not be published. Required fields are marked *