Module 1 · Lesson 0 Preview Beginner

HTTP Essentials

10 min read

Why HTTP Matters for CDNs

Before we dive into CDNs, we need to establish a shared understanding of HTTP—the protocol that powers the web. This isn't a comprehensive HTTP course, but these fundamentals are essential for understanding how CDNs work.

Here's the key insight: CDNs are HTTP-aware caches. They make decisions based on HTTP methods, headers, and status codes. If you understand these, you understand how to control CDN behavior.

The Request-Response Cycle

HTTP is a request-response protocol. A client (usually a browser) sends a request, and a server sends back a response. Every web interaction follows this pattern:

  1. Client sends request — "Give me this resource"
  2. Server processes — Finds or generates the resource
  3. Server sends response — The resource (or an error)
  4. Connection closes — (or stays open for reuse)

This is stateless—each request is independent. The server doesn't remember previous requests unless you explicitly pass state (via cookies, tokens, etc.).

HTTP Methods

HTTP methods (also called "verbs") indicate what action the client wants to perform:

Method Purpose Cacheable? Safe?
GET Retrieve a resource Yes Yes
POST Submit data / create resource Rarely No
PUT Replace a resource entirely No No
PATCH Partially update a resource No No
DELETE Remove a resource No No
HEAD GET without response body Yes Yes
OPTIONS Get allowed methods No Yes
Common HTTP Methods

Safe means the method doesn't modify server state—it only retrieves. Cacheable means responses can typically be stored and reused.

Anatomy of a Request

TEXT
GET /api/products/123 HTTP/1.1
Host: example.com
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)
Accept: application/json
Accept-Encoding: gzip, br
Cache-Control: no-cache
Example HTTP Request

A request consists of:

  • Request line — Method, path, and HTTP version
  • Headers — Metadata about the request (Host, Accept, etc.)
  • Body — (Optional) Data sent with POST/PUT requests

Anatomy of a Response

TEXT
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 256
Cache-Control: public, max-age=3600
ETag: "abc123"
Age: 120

{"id": 123, "name": "Widget", "price": 29.99}
Example HTTP Response

A response consists of:

  • Status line — HTTP version, status code, and reason phrase
  • Headers — Metadata about the response (Content-Type, Cache-Control, etc.)
  • Body — The actual content (HTML, JSON, image bytes, etc.)

Status Codes

Status codes tell you what happened with your request. They're grouped by first digit:

Range Category Common Examples
1xx Informational 100 Continue, 101 Switching Protocols
2xx Success 200 OK, 201 Created, 204 No Content
3xx Redirection 301 Moved Permanently, 304 Not Modified
4xx Client Error 400 Bad Request, 401 Unauthorized, 404 Not Found
5xx Server Error 500 Internal Server Error, 502 Bad Gateway, 503 Service Unavailable
HTTP Status Code Families

Headers: The Control Plane

Headers are key-value pairs that control HTTP behavior. For CDNs, certain headers are critical:

Header Direction Purpose
Cache-Control Response Primary caching directives (we'll cover this extensively)
ETag Response Version identifier for conditional requests
Vary Response Which request headers affect caching
Age Response How long content has been in cache
If-None-Match Request Conditional GET with ETag
Host Request Which origin to contact
CDN-Critical Headers (Preview)

We'll explore each of these in depth in Module 3 (Headers & Configuration). For now, just know that headers are how you control CDN caching behavior.

HTTP Versions

You'll encounter different HTTP versions:

  • HTTP/1.1 — Still widely used, text-based, one request per connection (or pipelining)
  • HTTP/2 — Binary, multiplexed (many requests over one connection), header compression
  • HTTP/3 — Uses QUIC instead of TCP, better performance on unreliable networks

The caching semantics are the same across versions—what changes is the transport efficiency. CDNs typically support all versions and often upgrade connections automatically.

Key Takeaway

Quick Check

Which HTTP methods are typically cached by CDNs?

Correct! Not quite.
Explanation

CDNs typically only cache GET and HEAD requests. These are 'safe' methods that don't modify server state—they only retrieve information. POST, PUT, DELETE, and PATCH modify data and are passed directly to the origin server.

Quick Check

What does the HTTP status code 304 indicate?

Correct! Not quite.
Explanation

304 Not Modified means the cached content is still valid. This happens during cache revalidation—the client or CDN asks 'has this changed?' and the origin responds 'no, use what you have.' This saves bandwidth by not re-transferring unchanged content.

Enjoying this preview?

Unlock all lessons, hands-on exercises, and earn your CDN certification.

Get Full Access

Ready to Master CDN?

You've just scratched the surface. Create a free account to access the full course, hands-on exercises, and earn your CDN Certified credential.

Free intro module Track progress Certificate

No credit card required · Free forever tier available