best way to explain interview question: what happens when you enter a web address
What happens when you type a URL in the web browser?
Ever wondered what happens when you type a URL in the browser? Information technology is a commonly asked question in technical interviews. In this weblog, we will see what happens in the background, step past step when nosotros type whatsoever URL. And so, let's become started.
1. You lot enter the URL in the browser.
Suppose you want to visit the website of AfterAcademy. So you blazon afteracademy.com in the address bar of your browser. When you type any URL yous basically want to reach the server where the website is hosted.
2. The browser looks for the IP address of the domain name in the DNS(Domain Proper name Server).
DNS is a list of URLs and their corresponding IP accost just like the phone book has phone numbers respective to the names of the people. We can access the website straight by typing the IP address simply imagine remembering a group of numbers to visit whatever website. So, we simply remember the name of the website and the mapping of the name with the IP address is done past the DNS.
The DNS checks at the post-obit places for the IP accost.
- Check Browser Cache: The browser maintains a cache of the DNS records for some fixed amount of time. Information technology is the first place to run a DNS query.
- Cheque OS Cache: If the browser doesn't contain the enshroud then it requests to the underlying Operating Organization as the Os also maintains a cache of the DNS records.
- Router Cache: If your reckoner doesn't accept the cache, then it searches the routers as routers as well have the cache of the DNS records.
- ISP(Isp) Cache: If the IP address is not found at the higher up 3 places and so it is searched at the enshroud that Internet access provider maintains of the DNS records. If not constitute here too, then Internet access provider'south DNS recursive search is washed. In "DNS recursive search", a DNS server initiates a DNS query that communicates with several other DNS servers to detect the IP address.
So, the domain proper noun which you entered got converted into a DNS number. Suppose the higher up-entered domain proper noun afteracademy.com has an IP address 100.95.224.1. So, if we type https://100.95.224.1 in the browser nosotros tin can reach the website.
3. The Browser initiates a TCP connectedness with the server.
When the browser receives the IP address, it will build a connection between the browser and the server using the internet protocol. The nearly mutual protocol used is TCP protocol. The connection is established using a three-manner handshake. Information technology is a 3-step process.
- 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 advice.
- Pace 2 (SYN + ACK): If the server is ready to accept connections and has open up ports then it acknowledges the packet sent by the server with the SYN-ACK packet.
- Step iii (ACK): In the final step, the client acknowledges the response of the server by sending an ACK package. Hence, a reliable connection is established and data transmission can get-go at present.
4. The browser sends an HTTP request to the server.
The browser sends a GET asking to the server request for afteracademy.com webpage. It will also send the cookies that the browser has for this domain. Cookies are designed for websites to retrieve stateful information (items in the shopping cart or wishlist for a website like Amazon) or to tape the user'southward browsing history etc. It too has additional information similar request header fields(User-Agent) for that allows the customer to pass information about the request, and about the customer itself, to the server. Other header fields similar the Accept-Language header tells the server which language the customer is able to understand. All these header fields are added together to class an HTTP request.
Sample Example of HTTP Asking: Now let's put it all together to form an HTTP request. The HTTP request below will fetch abc.html page from the spider web server running on afteracademy.com
GET /abc.htm HTTP/one.1 User-Agent: Mozilla/4.0 (uniform; MSIE5.01; Windows NT) Host: world wide web.afteracademy.com Accept-Linguistic communication: en-us Accept-Encoding: gzip, deflate Connection: Continue-Alive
5. The server handles the incoming request and sends an HTTP response.
The server handles the HTTP asking and sends a response. The first line is called the status line. A Status-Line consists of the protocol version(e.thousand HTTP/1.1) followed by numeric condition code(e.thousand 200)and its associated textual phrase(e.g OK). The status code is important as information technology contains the status of the response.
- 1xx: Informational: It ways the request was received and the process is continuing.
- 2xx: Success: It means the action was successful.
- 3xx: Redirection: It ways further activeness must exist taken in order to complete the request. It may redirect the client to some other URL.
- 4xx: Customer Error: It means some sort of mistake in the client's part.
- 5xx: Server Fault: It means in that location is some error on the server-side.
It also contains response header fields like Server, Location, etc. These header fields give information nigh the server. A Content-Length header is a number denoting the exact byte length of the HTTP body. All these headers along with some boosted data are added to grade an HTTP response.
Sample Instance of HTTP Response: Now let'due south put information technology all together to form an HTTP response for a asking to fetch the abc.htm page from the web server running on afteracademy.com.
HTTP/1.ane 200 OK Engagement: Tue, 28 January 2020 12:28:53 GMT Server: Apache/ii.2.14 (Win32) Final-Modified: Midweek, 22 Jul 2019 19:15:56 GMT Content-Length: 88 Content-Type: text/html Connectedness: Closed
vi. The browser displays the HTML content.
Now the browser gets the response and the HTML web folio is rendered in phases. First, information technology gets the HTML structure and so it sends multiple Go requests to become the embedded links, images, CSS, javascript files, etc and other stuff. The spider web page volition be rendered and in this case, the afteracademy spider web folio will be displayed.
All these steps happen each time nosotros enter any URL. All these processes happen in the groundwork and inside milliseconds. That's it for this blog. Hope you enjoyed reading this weblog.
Do share this weblog with your friends to spread the noesis. Visit our YouTube channel for more content. You tin can read more blogs from here.
Go on Learning :)
Squad AfterAcademy!
Source: https://afteracademy.com/blog/what-happens-when-you-type-a-url-in-the-web-browser
0 Response to "best way to explain interview question: what happens when you enter a web address"
Post a Comment