What happens when you enter a URL in your browser?

  Google
Add Your Answer
Answers (4)

At a high level:

  1. User types in URL
  2. Request goes to Domain Name Server (assuming the info is not cached) which returns IP address of the URL to the browser
  3. The browser request page from the IP address
  4. Server at IP address proceses the request and return HTML page
  5. Browser renders the HTML
The above steps are optimized at different levels:
  • Browser, OS, ISP may chache the mapping of domain name and IP – If information is found, then request is not routed further
  • Routing to DNS is first to a Recurssive DNS, which caches the information if it was requested earlier. If not found, it passes the request to other Recurssive DNSs. If still not found, then the request is made to an Authoritative DNS, which is the manager of the domain and maintains all details related to the domain (A record, etc)
  • HTML/ associated JS, CSS, image, etc files are also cached at browser, Load balancers, edge servers to allow for quicker access

When a person types in any url, the aim of the user is to basically reach the server where the website is hosted so that one can view/engage with its contents

So, the very first step that the browser takes to reacht the server is to looks for the IP address of the domain name in the DNS.

  1. DNS is a list of urls and their corresponding IP address similar to a telephone directory
  2. The DNS checks for the IP address at the following places;
    1. Checks Browser’s Cache
    2. Checks OS Cache
    3. Router Cache
    4. ISP Cache
    5. If not found here, DNS does a recursive search, i.e, DNS initiates a DNS query that communicates with several other DNS servers to find the needed IP
Once the Needed IP is found, Next the browser initiates a connection with the server using the internet protocol. The most common protocol is TCP protocol-a 3 step process
  1. Step 1 (SYN): As the client wants to establish a connection so it sends an SYN(Synchronize Sequence Number) to the server which informs the server that the client wants to start a communication.
  2. Step 2 (SYN + ACK): If the server is ready to accept connections and has open ports then it acknowledges the packet sent by the server with the SYN-ACK packet.
  3. Step 3 (ACK): In the last step, the client acknowledges the response of the server by sending an ACK packet. Hence, a reliable connection is established and data transmission can start now.

Next, the Browser sends a GET request to the server asking for a URL. It’ll also send the cookies if any. Cookies aree designed for the browsers to remember stateful information or to record the user’s browsing history. The Cookies also send other information like information about the user through differentheaders.

The server handles such a request and sends a response. The response has codes like 200 to convey different things.

  1. 1XX : Req was received and is still processing
  2. 2XX: Req was successful
  3. 3xx: Request is forwarded/redirected to complete the rocess
  4. 4xx: Client side error
  5. 5xx: Server side error
Along with the code, the response also has information about the server like its location
Now, finally the response received is rendered to give the final page in parts that we get once a url is clicked enter
  1. First the HTML structure
  2. Next multiple requests are sent tht gives the rendered pictures, links, CSS, javascript etc..
These are the steps that happen everytime a  user enters a url.

I am assuming the user is trying to enter www.google.com”

1. The key “g” or “w” is pressed
– Keyboard interrupt
– The keyboard sends signals on its interrupt request line (IRQ), which is mapped to an interrupt vector (integer) by the interrupt controller. The CPU uses the Interrupt Descriptor Table (IDT) to map the interrupt vectors to functions (interrupt handlers) which are supplied by the kernel. When an interrupt arrives, the CPU indexes the IDT with the interrupt vector and runs the appropriate handler. Thus, the kernel is entered. (USB keyboards slightly different)
– browser auto completes
– When you just press “g” the browser receives the event and the entire auto-complete machinery kicks into high gear. Depending on your browser’s algorithm and if you are in private/incognito mode or not various suggestions will be presented to you in the dropbox below the URL bar. Most of these algorithms prioritize results based on search history and bookmarks.
2. Then determine URL or search term? (Common in
– parse URL: by finding protocol “http” and “/“ resources to identifying whether it is a URL
– if not then it takes the entered text and passes it to its default search engine to search the term
– HSTS list: if URL, then browser checks its pre-loaded HSTS list. if the site mentioned is in browsers it hsts list then sends a https request
3. once the browser has the URL it starts by looking up for an IP address, through DNS lookup in the following order:
– Browser cache
– OS cache
– router cache
– ISP cache
– if not in any of the above then the ISP’s DNS server does a recursive search starting with the root name server
4. for major websites the IP address returned is of load balancers.
5. browser opens a TCP connection to server (this step is much more complex with HTTPS)
– it takes that and the given port number from the URL (the HTTP protocol defaults to port 80, and HTTPS to port 443)
– Client sends SYN packet: Client chooses an initial sequence number (ISN) and sends the packet to the server with the SYN bit set to indicate it is setting the ISN
– Server sends SYN-ACK packet back: copies the (client ISN +1) to its ACK field and adds the ACK flag to indicate it is acknowledging receipt of the first packet
– client answers with ACK packet; establishing a 3-way TCP connection.
6. browser then sends a HTTP ‘GET’ ‘request’ to the loadbalancer over the TCP connection
7. browser receives the ‘response’ from the loadbalancer a re-direct (301 message) to the appropriate data center. and eventually closes the TCP connection.
8. browser opens a TCP with the data center.
– browser then sends ‘GET’ request to the data-center and then again a permanent re-direct from http://google.com to http://www.google.com; also some sites may even re-direct towards geo-location aka google.com to google.in or google.de etc.
9. Now finally the browser has the IP address the of the real server. It needs to send the HTTP ‘GET’ request (over the TCP connection)
10. the google.com server handles the request listening on port 80;
– if the page is cached it will be returned immediately. if not other services (like db, application servers etc.) will be called to get the page.
– the server returns a 200 OK response along with the page content.
11. The browser then starts rendering the HTML content
– as part of the content it will see all URL’s for other assets like images/SSL certificates. and sends GET request for these requests.

This isn’t just a Google technical PM interview question; I’ve heard it at other companies, too.

When you type a URL, the browser check its cache if the website has been previously accessed. If yes, then the page is rendered from the cache, if not the browser makes a DNS request to OS. The OS sends request to the service provider for the requested DNS:
1) the request goes to the root server (which root domain has the information)
2)the request then goes to the TLD servers (which provides the exact location of the domain requested)
3)the request then goes to the name server and checks zone registry to return the IP of the requested domain.

Once the IP is retrieved. The browser established a TCP/IP connection and will start sending the data.

TCP/IP has following processes:
1) Handshake in form of client hello and server hello (high level detail of protocol and unique identifiers)
2) server send certificate
3) certificate is verified
4) The data is broken into several packets and then on top of that we add sender’s and reciever’s address, along with mac address.