HTTP & status codes · Lesson 3 of 9 · 3 min read
3xx redirection and caching
Redirect codes
| Code | Permanent? | Method on redirect | Use |
|---|---|---|---|
| 301 Moved Permanently | Yes | Browsers may change POST → GET | Canonical URLs, domain moves, HTTP → HTTPS |
| 302 Found | No | May change POST → GET | Temporary redirects (login flows) |
| 303 See Other | No | Always GET | After a POST form, redirect to a result page |
| 307 Temporary Redirect | No | Keeps method and body | Temporary redirect of APIs/POSTs |
| 308 Permanent Redirect | Yes | Keeps method and body | Permanent moves of APIs |
- 301s are cached by browsers, sometimes indefinitely — a wrong 301 is hard to undo. Test with 302 first.
- HTTP → HTTPS on an ALB: a port-80 listener whose default action is a redirect to HTTPS with 301 (
alb.ingress.kubernetes.io/ssl-redirect: '443'with the LB Controller). - Redirect loops (
ERR_TOO_MANY_REDIRECTS) often come from TLS terminating at the LB: the app sees plain HTTP, redirects to HTTPS, the LB forwards as HTTP again... Fix: the app must trustX-Forwarded-Proto. - Follow redirects in curl with
-L.
Enlarge diagram
Swipe sideways to see all of it, or tap to open it full screen.
304 Not Modified
Conditional requests save bandwidth: the client sends If-None-Match: "<etag>" (or If-Modified-Since); if unchanged, the server answers 304 with no body and the client uses its cached copy. CDNs and browsers rely on it heavily.
Enlarge diagram
Swipe sideways to see all of it, or tap to open it full screen.