Responses
Success and redirects
Choose common 2xx and 3xx status codes and understand how browsers follow Location headers or reuse cached responses.
Success responses live in the 2xx range. Redirects and cache checks live in 3xx. Both are normal outcomes, not errors.
Common 2xx codes:
200 OK: general success with a body.201 Created: a new resource now exists (typical after POST).204 No Content: success, but no body to return (common after DELETE).
3xx responses usually include a Location header telling the client where to go next:
HTTP/1.1 301 Moved Permanently
Location: https://flaviocopes.com/download/
301 and 308 mean permanent moves. Search engines and bookmarks should update to the new URL. 302 and 307 mean temporary moves.
There is a subtle method rule. 307 and 308 require the client to repeat the same method at the new URL. Old client behavior around 301 and 302 sometimes turned a POST into a GET on the redirect target. For form submissions that must stay POST, prefer 307 or 308.
304 Not Modified is a 3xx code, but it is not a redirect. The client asked “do I still have the latest copy?” and the server answered “yes, use your cache.” No body travels in that case.
Watch a redirect chain:
curl -I -L https://flaviocopes.com/books
You may see a 301 with Location: /download/, then a 200 on the final URL after curl follows -L.
Compare with a cached validation request in DevTools: a 304 row often has a tiny response size because the browser reused stored bytes.
My advice: pick permanent vs temporary deliberately when you configure redirects in your host or framework. Permanent codes consolidate SEO signals; temporary codes tell clients not to rewrite bookmarks yet.
Try this on your own project: list every redirect your site emits and mark each as permanent or temporary. Check whether any POST route redirects with a code that might change the method.
Lesson completed