Networking: DNS Caching and TTL
See how resolvers count TTLs down, why NXDOMAIN answers are cached too, and how to schedule a DNS cutover so stale answers expire.
How requests really travel: DNS lookups, TCP and TLS handshakes, HTTP caching and status codes, CORS and preflight, WebSockets, and how to debug a slow or failing call.
Official reference: MDN: HTTP
See how resolvers count TTLs down, why NXDOMAIN answers are cached too, and how to schedule a DNS cutover so stale answers expire.
Read real dig output for A, AAAA, CNAME, MX, TXT, NS, SOA and CAA records, and learn which combinations DNS rejects and why.
Test 301, 302, 303, 307 and 308 against a local Node server with curl and fetch, and see which codes turn a POST into a GET and why.
Why QUIC moves HTTP onto UDP, how browsers discover HTTP/3 through Alt-Svc and HTTPS records, and where its gains over HTTP/2 disappear.
Work out network, broadcast and usable hosts for any CIDR block by hand, check it with Python, and lay out a VPC that won't need renumbering.
Build a tiny L4 and L7 balancer in Node, watch keep-alive pin every request to one backend, and learn what each layer can route on.
Watch a home router report a 1492-byte path MTU, then learn how blocked ICMP and tunnel overhead create connections that hang on large packets.
Stall a Node TCP receiver, watch its receive window fill in netstat, and learn how window scaling and the BDP cap throughput on long links.
Read a real TLS 1.3 handshake from openssl s_client, compare it with TLS 1.2, and diagnose the certificate errors that break HTTPS clients.
Measure what keep-alive saves, size a client connection pool with Little's law, and retry safely when a pooled socket was closed under you.
CORS decides whether a page may read a cross-origin response, not whether it is sent. A browser test shows a blocked POST still saved.
Follow one DNS lookup from your laptop to the authoritative server with dig, and see why two users can get different answers after a move.
Use ETags for cheap 304 revalidation and to stop lost updates with If-Match, shown with curl against a small server that two editors share.
Who may store a response, how long it stays fresh and when it must be revalidated, shown with a toy CDN that leaks one user's page to another.
How Domain, Path, Secure, SameSite and expiry decide which requests carry a cookie, with curl's cookie jar showing each rule in action.
Safe and idempotent HTTP methods explained by sending POST, PUT, PATCH and DELETE twice to a real server, then making POST retries safe.
Read HTTP status codes as instructions: retry, fix the request, re-authenticate or check first, with a client decision function and its output.
HTTP/2 removes HTTP-level head-of-line blocking, but TCP's remains. See both in Node and curl, then compare what HTTP/3 over QUIC changes.
Why a gigabit connection doesn't make chatty APIs fast: count round trips, compare them with transfer time, and fix whichever term dominates.
Find the first failing step in a request (DNS, TCP, TLS, HTTP or the app) with curl timings, dig, nc and openssl, using six real failures.
What makes a browser send an OPTIONS preflight, how the server's answer gates the real request, and five preflights traced in a real browser.
Behind a reverse proxy your app sees the wrong scheme and client IP. Learn to read X-Forwarded-* safely, with a spoofing test you can run.
Why three socket writes can arrive as one read and one write as seventeen, and how to frame messages with delimiters or length prefixes.
How Server-Sent Events stream updates over plain HTTP, how EventSource resumes with Last-Event-ID after a drop, and what proxies do to streams.
What SYN, SYN-ACK and ACK agree on, why the kernel finishes the handshake before your app runs, and how refused differs from timed out.
Connect, first-byte, idle and total timeouts catch different failures. See each one fire against a stalling server, then budget retries sensibly.
Why encryption without a hostname check protects nothing, what a client verifies in a certificate, and the right fix for each TLS error.
What UDP gives up compared with TCP, shown with real Node experiments, and the sequencing, pacing and retry work your application takes on.
The WebSocket lifecycle from the 101 handshake to heartbeats, close codes and resuming after a drop, plus which server owns each connection.
The browser checks relevant caches and resolves the hostname through DNS if needed. It establishes a connection and negotiates TLS to authenticate the server and protect traffic. It sends an HTTP request, receives a response, and parses the document and its resources. Connection reuse, caching and the HTTP version can change the exact sequence. I would separate DNS, connection, server and rendering time when investigating a slow page.
Likely follow-up: How would you identify whether the delay is DNS or the server?
TCP provides an ordered byte stream with retransmission and flow control. Applications still need message framing and application-level error handling. UDP sends datagrams without guaranteeing delivery or order. It can suit latency-sensitive traffic where the application handles loss, but it is not automatically faster in every workload. Protocols built on UDP can add reliability: QUIC is an example. I would choose based on delivery requirements and the protocol ecosystem.
Likely follow-up: Why might a real-time application tolerate some packet loss?
A timeout does not prove the server did nothing. First determine whether the operation is safe to repeat. For a payment or order creation, use an idempotency key and have the server store or recover the result for that key. Limit attempts, apply exponential backoff with jitter and honor retry guidance where available. Retry transient failures rather than every error, and set an overall deadline so retries do not amplify an outage.
Likely follow-up: What happens if two requests with the same key arrive together?
Latency is the time required for an interaction or transfer step; bandwidth is the available data transfer rate. A small API response can be slow because of several sequential network round trips even when bandwidth is high. A large download may instead be limited by throughput. I would measure request timing and payload size, then reduce unnecessary round trips, compress suitable payloads or cache data according to the actual bottleneck.
Likely follow-up: Why might batching requests help on a high-latency connection?
Put a load balancer in front of healthy instances and choose a policy such as round robin or least connections based on workload. Configure health checks that reflect whether an instance can serve traffic and drain connections during removal. Keep application session state external or deliberately handle affinity. I would monitor latency, errors and instance load because equal request counts do not necessarily mean equal work. The balancer itself also needs an availability strategy.
Likely follow-up: How would long-lived connections affect balancing?
Resolvers and clients may still hold cached records from before the change. Records have a time to live, so changing an authoritative answer does not immediately invalidate every cached copy. Different users can consult different resolvers at different times. Before a migration, lower the relevant TTL sufficiently in advance and keep the old destination working during the transition. Diagnose by comparing answers from authoritative servers and the resolvers that affected clients use.
Likely follow-up: Why does lowering the TTL at the moment of cutover not clear old caches?
WebSockets suit frequent bidirectional communication such as interactive collaboration. Polling is often simpler when updates are infrequent and a little delay is acceptable. I would compare update frequency, infrastructure support and operational complexity before choosing. A WebSocket design needs authentication, reconnect behavior, heartbeats and backpressure. Reconnection alone does not recover missed events, so important updates need a sequence or resynchronization strategy. Long-lived connections also affect deployment and load balancing.
Likely follow-up: How would a client detect that it missed updates?
First identify which proxy generated the response and correlate its logs with backend request identifiers. A 502 generally indicates an invalid upstream response, while a 504 indicates an upstream timeout. Check target health, connection failures, resets, saturation and the timeout budgets of each hop. Compare failing and healthy requests and recent deployments. Increasing a timeout may hide overload, so measure queueing and service time before changing limits. Retry only when the operation is safe to repeat.
Likely follow-up: What happens when a client timeout is shorter than the backend timeout?
No questions match that filter.
Prefer multiple choice? All 11 Networking MCQs with answers →