In this post, I am going to talk about ‘what happen when you type an URL into your browser?’
For the example purpose, assume you opened a browser and entered the url ‘https://self-learning-java-tutorial.blogspot.com/search?q=pandas’. Here is a detailed analysis of what happens when you enter a URL into your browser.
1. URL Parsing
Browser parse the URL to get information about several components lie
a. scheme : https
b. Domain name: self-learning-java-tutorial.blogspot.com
c. Path: /search
d. Query parameters : q=pandas’
2. DNS resolution
Browser will find the IP address of the domain in this phase. Translating the domain name to IP address is called DNS lookup. In general, DNS lookup process looks like below
Browser maintain the ip address of the domain in its internal cache for a short period of time. First browser check the Ip address in its internal cache. If not found, it request operating system for the IP address of the given domain. Operating system also checks its internal cache, if it is not found, then OS trigger a call to DNS server over the internet to resolve the IP address
3. Establish TCP connection
Browser establish a connection to the IP address with the scheme (http, https etc.,) that we identified in ‘URL parsing’ phase. The steps to establish a connection will vary from scheme to scheme. For example, in case of https, the browser initiates a TLS/SSL (Transport Layer Security/Secure Sockets Layer) handshake while establishing the connection.
4. Send http request
Once the connection is established, browser send http request to the server. This request contain various information like
a. HTTP method : GET, POST, DELETE, OPTIONS etc.,
b. HTTP headers
c. Request path and query parameters
d. Request payload
e. Request cookies etc.,
5. Server processing
Server receive and process the incoming request.
6. Server send response
Server send the response back to client. This contain various information like
a. Response body
b. Response headers (status codes, ttl etc.,)
7. Browser receive, render and display the content
What about connection closing?
To improve the efficiency, HTTP connection can be kept alive for multiple requests to the same server. The connection can be closed for various reasons.
a. When client is done with server, then client can initaiton connection closing request using the Connection: close header.
b. When a predefined timeout or idle period.
c. When the server or client encounters an error or connection issue.
What is a DNS server?
DNS server is responsible translating a human readable domain name to IP addresses and vice versa.
Who maintain DNS servers?
DNS servers are maintained by a variety of organizations, including:
a. Internet Assigned Numbers Authority (IANA)
b. Internet service providers (ISPs)
c. Domain name registrars
d. Large companies or organizations that operate their own networks
e. The Internet Corporation for Assigned Names and Numbers (ICANN)
f. Government Entities
How operating system knows which DNS server to contact?
When a computer/device connects to Internet, it uses ‘Dynamic Host Configuration Protocol’ to obtain network configuration information, including the IP address of a DNS server. The information you get will change based on the network you connect to.
Some users opt to use third-party DNS services like Google Public DNS, Cloudflare DNS, or OpenDNS. They manually configure their devices to use these services, which have fixed IP addresses.
For example, following are the IP addresses of Google public DNS.
IPv4 Address:
Primary DNS Server: 8.8.8.8
Secondary DNS Server: 8.8.4.4
IPv6 Address:
Primary DNS Server: 2001:4860:4860::8888
Secondary DNS Server: 2001:4860:4860::8844
You can explicitly specify nslookup command to use which DNS to use while querying for IP addresses.
Syntax
nslookup MY_DOMAIN 8.8.8.8
Replace "MYDOMAIN" with the domain name you want to look up, and the command will query Google Public DNS (8.8.8.8) for the IP address associated with the domain.
Example
nslookup https://self-learning-java-tutorial.blogspot.com 8.8.8.8
$ nslookup https://self-learning-java-tutorial.blogspot.com 8.8.8.8
Server: 8.8.8.8
Address: 8.8.8.8#53
Non-authoritative answer:
https://self-learning-java-tutorial.blogspot.com canonical name = blogspot.l.googleusercontent.com.
Name: blogspot.l.googleusercontent.com
Address: 142.250.76.65
No comments:
Post a Comment