# HTTP and HTTPS

> The request/response protocol every web page and API call uses: methods, status codes, headers, caching and TLS. Free notes, key concepts, resources and a mini...

Canonical: https://www.internhack.in/roadmaps/tracks/frontend/http
Last updated: 2026-11-28

The request/response protocol every web page and API call uses: methods, status codes, headers, caching and TLS.

Beginner · about 4 hours · difficulty 2/5

Learn first: [DNS and Domain Names](https://www.internhack.in/roadmaps/tracks/frontend/dns)

**HTTP** is a text-based conversation between a client and a server. The client sends a request (method, path, headers, optional body) and the server replies with a status code, headers and a body. Almost everything you build on the frontend ends up as HTTP traffic, so reading it fluently is a superpower.

### The pieces

- **Methods**: `GET` (read, no body, safe to repeat), `POST` (create or trigger), `PUT`/`PATCH` (replace/update), `DELETE`. `OPTIONS` shows up in CORS preflights.
- **Status codes**: 2xx success (200, 201, 204), 3xx redirects (301, 302, 304 Not Modified), 4xx client errors (400, 401, 403, 404, 429), 5xx server errors (500, 502, 503).
- **Headers** carry metadata: `Content-Type`, `Authorization`, `Cookie`/`Set-Cookie`, `Cache-Control`, `ETag`, `Accept-Encoding`.
- **Cookies** are small values the server asks the browser to store and send back automatically, which is how sessions work.

### HTTPS and versions

HTTPS is HTTP inside a **TLS** encrypted connection. Certificates prove the server owns the domain. Modern browsers block many features (service workers, geolocation, clipboard) on plain HTTP except on localhost. HTTP/1.1 opens several connections; **HTTP/2** multiplexes many requests over one; **HTTP/3** uses QUIC for faster setup on flaky networks.

### Caching basics

`Cache-Control: max-age=31536000, immutable` tells the browser a file never changes (perfect for hashed build assets). `no-cache` means "revalidate before use", and `ETag` lets the server answer 304 without resending the body.

### Good enough to move on

Open the DevTools Network tab on any site and explain what each request is, why it got its status code and whether it came from cache.

## Key concepts

- **Request and response anatomy**
- **HTTP methods**
- **Status codes**
- **Headers and content types**
- **Cookies and sessions**
- **HTTPS, TLS and certificates**
- **Cache-Control and ETag**
- **HTTP/2 and HTTP/3**
- **DevTools Network panel**

## Mini project

Use curl -v and the DevTools Network panel to fetch a public API; annotate one request and response line by line, including every header and why the status code was returned.

## Check yourself

What is the difference between a 401 and a 403 response, and between Cache-Control no-cache and no-store?

## Free resources

- [HTTP](https://developer.mozilla.org/en-US/docs/Web/HTTP) (MDN)
- [HTTP caching](https://web.dev/articles/http-cache) (web.dev)

Previous: [DNS and Domain Names](https://www.internhack.in/roadmaps/tracks/frontend/dns) · Next: [How Browsers Render a Page](https://www.internhack.in/roadmaps/tracks/frontend/browser-rendering)

## More in How the Web Delivers a Page

- [How the Internet Works](https://www.internhack.in/roadmaps/tracks/frontend/internet)
- [DNS and Domain Names](https://www.internhack.in/roadmaps/tracks/frontend/dns)
- [HTTP and HTTPS](https://www.internhack.in/roadmaps/tracks/frontend/http)
- [How Browsers Render a Page](https://www.internhack.in/roadmaps/tracks/frontend/browser-rendering)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [Frontend Developer Roadmap](https://www.internhack.in/roadmaps/tracks/frontend)
