What happens when you type a URL in the browser and press Enter?

Step by step from typing a URL to seeing the page: cache, DNS, TCP and TLS handshakes, the HTTP request, the server side, and rendering.

0 0
Read Time:1 Minute, 57 Second

There is no single right depth. Give the whole path in a minute, then go deeper wherever the interviewer points. Example: https://www.example.com/jobs.

1. Parse and check caches

The browser checks that it is a URL and not a search, then looks in its cache. With HSTS it knows to use HTTPS even if you typed http.

2. DNS: turn the name into an IP address

Browser cache, then the operating system cache and hosts file, then the configured resolver (your ISP or 8.8.8.8, for example). On a miss, the resolver asks a root server, then the .com server, then the domain’s authoritative server, and caches the answer for its TTL.

3. TCP connection

A three-way handshake to port 443: SYN, SYN-ACK, ACK. (HTTP/3 uses QUIC over UDP instead and merges this with the next step.)

4. TLS handshake

Browser and server agree on a cipher, the server sends its certificate, the browser checks it against trusted certificate authorities and the domain name, and both derive session keys. Everything after this is encrypted.

5. HTTP request

GET /jobs HTTP/2
Host: www.example.com
Accept: text/html
Cookie: session=...

6. On the server side

Typically: CDN or load balancer, then a web server or reverse proxy, then the application, which checks the session, may query a database or cache, and builds the response.

7. The response

HTTP/2 200
Content-Type: text/html; charset=utf-8
Cache-Control: max-age=60

A redirect (301/302) would send the browser to another URL and start again.

8. Rendering

The browser parses HTML into the DOM and CSS into the CSSOM, fetches the scripts, styles and images it finds (often over the same connection), runs JavaScript, builds the render tree, then lays out and paints the page.

Where interviewers like to dig

  • Recursive versus iterative DNS queries, and DNS record types (A, AAAA, CNAME, MX).
  • What a certificate authority is and why the padlock matters.
  • Keep-alive and HTTP/2 multiplexing.
  • How a CDN speeds up step 6.
  • Render-blocking CSS and JavaScript.

This answer was written by Debugger’s Space as practice material. It is asked in most Indian IT services interviews (TCS, Infosys, Wipro, HCLTech, Tech Mahindra, LTIMindtree, Accenture, Cognizant, Capgemini, IBM). See each company’s hiring steps and practice questions on Debugger’s Space.

Previous post What do the ACID properties mean?
Next post What is the difference between REST and SOAP? Which HTTP methods are idempotent?
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Close
0
Would love your thoughts, please comment.x
()
x