From link to page: DNS and the full journey
Lesson 2 of 3
2From link to page: DNS and the full journey
The big picturePeople remember names; machines need numbers. DNS is the phone book that translates between them, and it is asked millions of times a second.
What the picture shows: Five stops in under a second. Each stop has its own lesson; this one ties them into a single journey.
Map of this part
The concepts in order, click any one to jump to it:
Two ways into the same idea
When you tell a driver "take me to the restaurant on Main Street", they need coordinates. They ask the map app (DNS) for the location, drive there (the connection), check it is the real restaurant and not a fake (TLS), then you order (HTTP) and eat (rendering).
Resolution: browser → OS cache → the ISP's recursive resolver → root servers → the TLD server (.com) → the domain's authoritative server, which returns an A (IPv4) or AAAA (IPv6) record. Each answer has a TTL that sets how long it is cached. Then the TCP handshake, then the TLS 1.3 handshake (the server's certificate is signed by a trusted authority), then the HTTP request, then parsing HTML, building the DOM and CSSOM, and painting.
Before You Start
📡Networks and addresses
You know IPs, ports and TCP.
The Core Idea
1The parts of a URL
https://shop.example.com:443/cart?id=7#pay: scheme https, host shop.example.com, port 443, path /cart, query id=7, and the fragment #pay is never sent to the server; only the browser uses it.
from urllib.parse import urlsplit, parse_qs
url = "https://shop.example.com:443/cart?id=7&lang=ar#pay"
p = urlsplit(url)
print("scheme:", p.scheme)
print("host:", p.hostname, "port:", p.port)
print("path:", p.path)
print("query:", parse_qs(p.query))
print("fragment:", p.fragment)2DNS: the internet's phone book
The browser asks: "what is the address of shop.example.com?". If no answer is cached, it asks a resolver, which asks a chain of servers from the root down to the domain's server. The answer is cached for its TTL, which is why moving a server can take hours to reach everyone.
nslookup example.com # or on Linux / macOS dig example.com +short
3TLS: the padlock in the address bar
Before any data, the browser and server agree on encryption keys, and the server presents a certificate proving it owns the name, signed by an authority the browser trusts. After that, nobody on the way (a café network, say) can read or change what passes between you.
4The browser draws the page
HTML arrives and the browser builds a tree from it called the DOM, reads CSS to know the look, and runs JavaScript that may change the tree. Then it computes where each element goes (layout) and draws it (paint). Every extra CSS or JS file is another trip, which is why heavy pages are slow.
Worked example
Problem: your company site moved to a new server and some staff still see the old one. Analysis: the name is still cached in their DNS with the old address because the TTL was 24 hours. Fix: wait out the TTL or flush the DNS cache (ipconfig /flushdns), and next time lower the TTL to 5 minutes before moving.
Myth vs Reality
| Myth | Reality |
|---|---|
| The padlock means the site is safe and trustworthy. | It only means the connection is encrypted to whoever owns the name. A scam site can get a certificate for its own name. |
| The part after # reaches the server. | It is never sent; the browser uses it to jump within the page, or front-end apps use it. |
Test your understanding
What does DNS do?
DNS is a phone book: a name goes in, an address comes out.
Which part is not sent to the server in https://a.com/p?x=1#top?
The fragment after # stays in the browser.
Why does a DNS change reach some people late?
Every resolver keeps the old answer until its time is up.
Quick review cards
Check Your Understanding
Order these: TLS, DNS, painting, HTTP request, TCP connection.
DNS, then TCP, then TLS, then the HTTP request, then painting.
What does the server certificate prove?
That the server owns the domain name you asked for, signed by an authority the browser trusts. It does not prove the owner is honest.
Why do many CSS and JS files slow a page?
Each file is another request, and the browser may hold off painting until CSS loads and some JS runs.
Resources for this lesson
Grouped by type. Start with the official docs for precision, or an article or video for the explanation.
Official docs1
Done with this lesson?
Sign in to save your progress.