Skip to main content

DNS and HTTP

DNS​

The Domain Name System maps names to IP addresses.

Resolution​

Browser cache -> OS cache -> Recursive resolver (ISP / 8.8.8.8)
-> Root server -> TLD server (.com) -> Authoritative server -> IP

Results are cached for the record's TTL.

RecordPurpose
A / AAAAName to IPv4 / IPv6
CNAMEAlias to another name
MXMail servers
NSAuthoritative name servers
TXTArbitrary text (SPF, verification)
dig +short prepverse.vercel.app

HTTP​

HTTP is a stateless request-response protocol, usually over TCP (HTTP/3 uses QUIC over UDP).

GET /docs HTTP/1.1
Host: prepverse.vercel.app
Accept: text/html

HTTP/1.1 200 OK
Content-Type: text/html
Cache-Control: public, max-age=0, must-revalidate

Methods​

MethodUseSafeIdempotent
GETReadYesYes
POSTCreate / actionNoNo
PUTReplaceNoYes
PATCHPartial updateNoNot guaranteed
DELETERemoveNoYes

Status codes​

RangeMeaningExamples
1xxInformational101 Switching Protocols
2xxSuccess200 OK, 201 Created, 204 No Content
3xxRedirection301 Moved, 304 Not Modified, 308 Permanent Redirect
4xxClient error400, 401, 403, 404, 429 Too Many Requests
5xxServer error500, 502, 503, 504

Versions​

VersionKey idea
HTTP/1.1Persistent connections, but head-of-line blocking
HTTP/2Multiplexed streams, header compression
HTTP/3QUIC (UDP): faster handshakes, no TCP head-of-line blocking

Cookies, caching and CORS​

  • Cookies add state on top of stateless HTTP (Set-Cookie, HttpOnly, Secure, SameSite).
  • Caching uses Cache-Control, ETag and Last-Modified for conditional requests.
  • CORS is a browser policy: a page may call another origin only if that server allows it with Access-Control-Allow-Origin.