HTTP/HTTPS
Updated June 6, 2026The Language of the Web
Every time you visit a website, your browser and the server are having a conversation. They need a shared language, agreed-upon rules for how to ask for things and how to respond. That language is HTTP (HyperText Transfer Protocol).
HTTP is simple in concept: you ask for something, you get a response. But modern web applications have pushed it far beyond its origins, and understanding how HTTP works, and how HTTPS secures it, is foundational for anyone building or designing web systems.
The Request-Response Cycle
The client (usually a browser, mobile app, or another service) sends a request. The server processes it and sends back a response. That's it.
Plain HTTP request and response in plaintext
A raw HTTP request looks like this:
GET /api/users/42 HTTP/1.1
Host: api.example.com
Authorization: Bearer eyJhbGci...
Accept: application/jsonAnd a response looks like:
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 128
{"id": 42, "name": "Alice", "email": "alice@example.com"}Both have a headers section (metadata about the request or response) and optionally a body (the actual content).
HTTP is also stateless, meaning each request is completely independent. The server doesn't remember anything about your previous requests. This is why cookies and sessions exist (to simulate statefulness on top of a stateless protocol).
HTTP is a stateless protocol, meaning the server remembers state between requests by default.
HTTP Methods
HTTP methods define the intent of a request. A solid REST API maps these to CRUD operations:
| Method | Meaning | Idempotent? | Has Body? |
|---|---|---|---|
| GET | Retrieve a resource | Yes | No |
| POST | Create a new resource | No | Yes |
| PUT | Replace a resource entirely | Yes | Yes |
| PATCH | Partially update a resource | No | Yes |
| DELETE | Remove a resource | Yes | No |
| HEAD | Like GET but returns only headers | Yes | No |
| OPTIONS | Ask what methods are allowed | Yes | No |
Idempotent means calling the same request multiple times has the same effect as calling it once. GET, PUT, and DELETE are idempotent. POST is not: posting the same order twice creates two orders.
The PATCH vs PUT distinction: PUT replaces the entire resource. If you PUT a user object and forget to include the
Which HTTP method is NOT idempotent?
Status Codes
Status codes tell the client what happened. They're grouped by their first digit:
2xx — Success
200 OK— standard success201 Created— resource was created (response to POST)204 No Content— success but nothing to return (common for DELETE)
3xx — Redirection
301 Moved Permanently— the resource has a new permanent URL302 Found— temporary redirect (browser follows but keeps using old URL)304 Not Modified— cached version is still valid; no need to re-download
4xx — Client Error
400 Bad Request— malformed request syntax401 Unauthorized— not authenticated403 Forbidden— authenticated but not allowed404 Not Found— resource doesn't exist429 Too Many Requests— rate limited
5xx — Server Error
500 Internal Server Error— generic server failure502 Bad Gateway— upstream server returned an invalid response503 Service Unavailable— server is overloaded or down for maintenance504 Gateway Timeout— upstream server took too long
The
401 vs 403distinction trips people up. 401 means "you're not logged in." 403 means "you're logged in, but you don't have permission." Always use the right one, as it affects how clients and security tools behave.
A request arrives with a valid session token but the user lacks permission to access the resource. Which status code should the server return?
HTTP Versions: 1.1, 2, and 3
HTTP has evolved significantly. Each version addresses the performance limitations of the previous one.
HTTP/1.1 (1997)
The workhorse of the web for decades. Introduced persistent connections (keep-alive) so multiple requests could reuse the same TCP connection instead of opening a new one each time.
The problem: HTTP/1.1 is head-of-line blocked at the request level. If one request is slow, subsequent requests queue up behind it on the same connection. Browsers work around this by opening 6-8 parallel connections per domain: a workaround, not a solution.
HTTP/2 (2015)
HTTP/2 is a major overhaul:
- Multiplexing: multiple requests and responses fly over a single TCP connection simultaneously, with no head-of-line blocking at the HTTP level
- Header compression: HTTP headers are repetitive; HTTP/2 compresses them with HPACK, saving bandwidth
- Server push: servers can proactively send resources the client will need (before the client asks)
- Binary protocol: more efficient to parse than HTTP/1.1's text format
HTTP/2 requires HTTPS in practice (all major browsers enforce this).
HTTP/3 (2022)
HTTP/3 replaces the underlying transport: instead of TCP, it runs on QUIC (over UDP). This fixes a fundamental problem: HTTP/2's multiplexing is still limited by TCP's head-of-line blocking at the transport layer. If a single TCP packet is lost, all streams wait.
QUIC implements its own reliability per-stream, so a lost packet only delays that stream, not every other request. HTTP/3 also has faster connection setup (0-RTT in some cases) and handles network changes better (useful on mobile when switching between WiFi and cellular).
| Feature | HTTP/1.1 | HTTP/2 | HTTP/3 |
|---|---|---|---|
| Transport | TCP | TCP | UDP (QUIC) |
| Multiplexing | No | Yes | Yes |
| Header compression | No | HPACK | QPACK |
| HOL blocking | Both levels | Transport level | None |
| TLS required? | No | Effectively yes | Yes |
What key problem does HTTP/3 solve that HTTP/2 could not fully address?
How HTTPS Works
HTTPS is HTTP with TLS (Transport Layer Security) on top. TLS encrypts the connection so that nobody between your browser and the server can read or tamper with the data.
TLS handshake establishing encrypted session key
Here's a simplified version of the TLS handshake:
- Client Hello: "I want to connect. Here are the TLS versions and cipher suites I support."
- Server Hello: "Here's the TLS version and cipher we'll use. Here's my certificate."
- Certificate verification: The client verifies the certificate is valid and signed by a trusted Certificate Authority (CA).
- Key exchange: Client and server use asymmetric cryptography (like RSA or ECDH) to agree on a shared session key without ever sending it directly over the wire.
- Symmetric encryption begins: All subsequent data is encrypted with the shared session key (symmetric crypto is much faster than asymmetric).
The certificate is the trust anchor. It proves the server is who it says it is, signed by a CA like Let's Encrypt, DigiCert, or Comodo. Your browser has a built-in list of trusted CAs.
TLS 1.3 (the current version) made the handshake faster; it completes in 1 round trip instead of 2, and supports 0-RTT resumption for previously-visited sites. Always use TLS 1.3 if you're configuring servers today.
During a TLS handshake, asymmetric cryptography is used for all data transferred after the handshake is complete.
TLS Termination
TLS termination at the edge of the private network
In production environments, a load balancer or reverse proxy acts as the entry point to the system and performs TLS termination. The proxy decrypts the incoming HTTPS traffic and passes it to internal application servers as plain HTTP over a private, secure network. This centralizes certificate administration and keeps encryption/decryption CPU overhead off your primary app servers.
HTTP Headers Worth Knowing
A few headers come up constantly in system design:
Authorizationcarries auth tokens (Bearer tokens, API keys)Content-Typetells the receiver what format the body is in (application/json,text/html, etc.)Cache-Controlcontrols caching behavior (no-cache,max-age=3600)ETagis a version identifier for resources, used with304 Not ModifiedCORS headers(Access-Control-Allow-Origin) controls cross-origin accessX-Request-IDis a trace ID for debugging requests across servicesRetry-Aftertells rate-limited clients when to try again
Summary
HTTP is the request-response protocol that powers the web. Requests have methods that express intent (GET, POST, PUT, DELETE), and responses have status codes that communicate outcomes. HTTP/1.1 is simple but inefficient; HTTP/2 adds multiplexing and compression over TCP; HTTP/3 moves to QUIC over UDP to eliminate transport-level head-of-line blocking. HTTPS layers TLS on top of HTTP, using a handshake to establish encrypted communication verified by certificates. These fundamentals underpin everything from REST APIs to microservice communication to CDN behavior; know them deeply and system design decisions become much clearer.
How helpful was this content?
Comments
Sign in to join the discussion
Saved on this device only
Sign in to sync progress across devices