What is an HTTP redirect?
Useful first: HTTP · optional, not a requirement
Choose your depth
Stay with the essentials, or look closer.
YOUR GOALExplain why reaching a page can involve a second request.
Follow the forwarding address
An answer that points somewhere else
Imagine opening a saved link to /old-guide. Instead of returning the guide, the server replies with a redirect and a destination. A browser following that response requests the new address. Think of a notice on a shop door giving its new location: the notice is not the shop itself.
For example, a 302 Found response with Location: /new-guide can lead a browser from a GET request for the old address to a GET request for the new one.
The destination still has to answer
The destination produces its own response. It might return a page, another redirect or an error. A forwarding notice does not prove the final page exists.
A permanent move tells clients that the new address should replace the old one. A temporary move leaves the original address as the one to use for future visits. Those meanings differ even when both redirects appear to take you to the same page today.
[3] [4]A redirect supplies a destination; the client still has to request it.
The redirect response already contains the final page at its new address.
Following a redirect involves another request. The response to that request determines what the destination actually returns.
Show the explanation
Make another GET request for /new-guide. The Location header supplies the next address. Following it means sending another request, whose response can succeed or fail.
YOUR GOALDistinguish a move from a change in request method.
Choose the next request deliberately
301 and 302 do not promise to preserve POST
301 Moved Permanently describes a permanent move; 302 Found describes a temporary one. For historical compatibility, HTTP permits a client to change POST to GET when following either response. Do not choose one merely because it appears to preserve a submitted form in one test.
The HTTP guide explains why a request method matters: retrieving a result and submitting data are different operations.
[3] [4] [8]307 and 308 keep the method and body
Use 307 Temporary Redirect for a temporary move that preserves the request method and body, or 308 Permanent Redirect for the corresponding permanent move. This describes the redirected request when the client follows it; it is not a promise that every client will automatically follow every redirect.
In a fictional upload service, a POST to /upload receives 307 with Location: /upload-here. Following it sends POST and the upload body to that destination, rather than replacing the submission with a GET.
303 retrieves the result of a submission
After accepting a form submission, a server can return 303 See Other and point to a confirmation resource. For an ordinary browser form flow, POST to /bookings can be followed by GET for /booking-confirmation. The follow-up retrieves the confirmation instead of resending the POST body.
More generally, 303 directs a retrieval request using GET or HEAD. It does not say that the original form address has permanently moved to the confirmation address.
[5] [8]Decide both whether the move is temporary and what the next request should do.
All redirect status codes send the same request to a different URL.
301 and 302 permit POST to become GET; 307 and 308 preserve the method and body, while 303 points to a retrieval of another resource.
Show the explanation
307 Temporary Redirect. 307 combines a temporary destination with method and body preservation. 308 preserves them too, but communicates a permanent move; 303 serves a different purpose.
YOUR GOALSeparate destination resolution, caching and chain behavior when diagnosing redirects.
Inspect the whole redirect chain
Resolve Location in context
Location can hold an absolute URL or a relative reference. For a request to https://example.com/docs/start, Location: next resolves to https://example.com/docs/next, while Location: /next resolves to https://example.com/next. The URL guide explains this resolution.
Read the status with the header. A 201 Created response can use Location to identify a newly created resource without instructing a redirect. Likewise, 304 Not Modified is a cache-validation result, not a move to a replacement URL.
Permanent does not mean cached forever
301 and 308 are eligible for heuristic caching, subject to request-method rules and explicit cache controls. A cache may estimate freshness when permitted and no explicit lifetime is supplied. An explicit expiration takes precedence over such estimates.
For example, a cacheable redirect with Cache-Control: max-age=60 supplies a 60-second freshness lifetime; the word permanent does not turn that into an infinite lifetime. Temporary redirects can also be cacheable when the applicable rules and response controls allow it. Inspect the redirect response itself as well as the final page, and use the caching guide to distinguish storage from freshness.
A chain must reach an answer
If /a redirects to /b and /b redirects back to /a, following the chain cannot reach a final page. Browsers detect redirect loops and report a failure. A longer chain that does terminate still requires extra requests.
For diagnosis, list each requested URL, its status, its Location value and the next request method. That record can reveal a loop or an unexpected POST-to-GET change that looking only at the final address would miss. Avoid unnecessary intermediate destinations; do not infer a measured speed improvement from their removal alone.
[1] [3] [4]Check each hop, its method and its cache policy; the final URL alone does not explain the journey.
A permanent redirect makes a cache remember it forever, regardless of response headers.
Permanence describes the move. Cache storage and freshness still follow method semantics and the applicable cache controls.
Show the explanation
It supplies a 60-second freshness lifetime, independent of the permanent-move meaning. The explicit lifetime governs freshness. A permanent move is not an instruction to disregard cache controls or to keep a stored response fresh forever.
Keep asking. Check the details.
Source-checked using AI (OpenAI Codex) on . The checks covered sources, examples, and quizzes for this article version.
No human review is claimed. AI review can miss errors; check the original sources below.
- MDN — Redirections in HTTP
- MDN — Location header
- MDN — 301 Moved Permanently
- MDN — 302 Found
- MDN — 303 See Other
- MDN — 307 Temporary Redirect
- MDN — 308 Permanent Redirect
- RFC 9110 — Redirection status codes
- RFC 9111 — Heuristic freshness