Course contentsShow
← Web Development
Lesson 1489 of 2,98227. REST API Design for FrontendFree lesson

3xx Redirection Status Codes

Understand 301, 302, 304 Not Modified, and how browsers handle redirects automatically.

3xx Redirection Status Codes

You'll learn: How browsers automatically follow redirects and what the most common 3xx status codes mean for your REST API.

When a server responds with a 3xx status code, it's saying "the resource you want is somewhere else" — like a forwarding address for a package. Browsers and HTTP clients typically handle these redirects automatically, seamlessly taking you to the new location.

The Core 3xx Codes

301 Moved Permanently

Indicates the resource has permanently moved to a new URL. Browsers cache this redirect, so future requests go directly to the new location. Search engines update their indexes accordingly.

Use case: You've restructured your API paths from /api/v1/users to /api/v2/users permanently.

302 Found (Temporary Redirect)

The resource temporarily lives at a different URL, but clients should keep using the original URL for future requests. Browsers don't cache 302s.

Use case: Temporarily redirecting traffic during maintenance or A/B testing.

304 Not Modified

A special redirect that says "the resource hasn't changed since you last fetched it — use your cached version." This requires conditional request headers like If-Modified-Since or If-None-Match.

Use case: Browser checks if a previously cached image is still current. Server responds with 304, saving bandwidth by not re-sending the file.

How Browsers Handle Redirects

When your browser receives a 3xx response, it automatically reads the Location header and makes a new request to that URL. You rarely see redirects happening — the browser just takes you to the final destination.

Key Takeaway: 3xx codes tell clients where to find resources: 301 for permanent moves, 302 for temporary ones, and 304 to reuse cached data efficiently.