Monday, February 23, 2015

What happens when you type in your browser's address bar from an Indian Location?

Skills - HTTP protocol, DNS Lookup, Networking, TCP connection, etc

There are series of events that happen when we type in into browser's address bar from a given location, we will cover few main steps here -
  • User enters into the address bar
  • Browser checks if the typed address is www url or the search term, if it is search term then it will use pre configured web search server (may be google or bing, etc) to search the typed term from web.
  • If the requested Object is in browser's cache and cache is valid, content is rendered from cache, otherwise
  • DNS Lookup takes place - Browser resolves the IP address for the mentioned server (
  1. It checks in the browser cache
  2. checks the OS Cache
  3. checks the router cache
  4. checks the ISP cache
  5. DNS recursive search until it reaches authoritative DNS Server. If multiple ip addresses are found for a given server address, then DNS Round Robin algorithm picks up any one for the further communication. If it does not recognize the domain then it gives error message.
  6. we can use <nslookup> command on windows to check what all IP addresses are mapped to this domain, incase they are multiple DNS server will use round robin algorithm to pick up any one from the list.
  • Browser initiates TCP connection with the IP address and issues HTTP GET request to the server, it passes along an HttpRequest that includes metadata about browser, user preferences (language, locale etc.) and cookies for that domain.
  • server receives the request, uses the passed information (cookies) to find who the user is, locale, language and region and  sends http redirects (HTTP GET 302) to browser to use local regional google server, i.e. in our case (temporarily redirect)
  • Browser receives the response (302 in this case) and sends a fresh request to the newly mentioned location in the previous response, passing the user information again (cookies for that domain, metadata, etc)
  • receives the request the decodes the user and send the appropriate HTML response including headers (status code 200 OK, content type, etc)
  • The Browser receives the response and begins to parse it for display. if it is compressed, browser will decompress it, The HTML body will include links to css, images, js. All these links will trigger additional calls back to server to retrieve those files. CDN (Content Delivery Networks) may serve these static resource requests to speedup the process.
  • Browser layout engine will start to assemble the final page for display. css, js information may alter the layout of the page.
  • The final page is assembled and rendered to the user.
  • After this the browser may send further AJAX request to communicate with the web server even after the page is rendered.
Also, there are many other things happening in parallel to this (processing typed-in address, adding page to browser history, displaying progress to user, notifying plugins and extensions, rendering the page while it's downloading, pipeline, connection tracking for keep-alive, etc.).

No comments:

Post a Comment

Your comment will be published after review from moderator