What happens when you type www.google.com in your browser's address bar?

Upasana | May 19, 2019 | 2 min read | 112 views

Skills Required

HTTP protocol, DNS Lookup, DNS Caching, Routing, Networking, TCP connection, Browser Cookie handling, CDN etc

There are series of events that happen when we type in www.google.com into browser’s address bar from a given location, we will cover few main steps here -

  1. User enters www.google.com into the address bar

  2. 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.

  3. If the requested Object is in browser’s cache and cache is valid, content is rendered from cache, otherwise

  4. DNS Lookup takes place - Browser resolves the IP address for the mentioned server (www.google.com)

    • It checks in the browser cache

    • Checks the OS Cache

    • Checks the router cache

    • Checks the ISP cach** 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. We can use command on windows to check what all IP addresses are mapped to this www.google.com domain, incase they are multiple DNS server will use round robin algorithm to pick up any one from the list.

  5. 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.

  6. Google.com 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. www.google.co.in in our case (temporarily redirect)

  7. 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)

  8. Google.co.in receives the request the decodes the user and send the appropriate HTML response including headers (status code 200 OK, content type, etc)

  9. 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.

  10. Browser layout engine will start to assemble the final page for display. css, js information may alter the layout of the page.

  11. The final page is assembled and rendered to the user.

  12. 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.).

Top articles in this category:
  1. Which data type would you choose for storing Monetary Values, Currency in Java
  2. Use ExecutorCompletionService to compute results from 5 different datasources in parallel
  3. Multi-threading Java Interview Questions for Investment Bank
  4. What is difference between HTTP Redirect and Forward
  5. Cracking core java interviews - question bank
  6. RBS Java Programming Interview Questions
  7. Citibank Java developer interview questions

Recommended books for interview preparation:

Find more on this topic:
Buy interview books

Java & Microservices interview refresher for experienced developers.