Some article I read once said that it means jumping (from one URI to another), but I detected this \"302\" even when there was actually no jumping at all!
From Wikipedia:
The HTTP response status code 302 Found is the most common way of performing a redirection. It is an example of industrial practice contradicting the standard.
EXAMPLE:- Although it is not very common that we find ourselves in need of a 302 redirect, this option can be very useful in some cases. These are the most frequent cases:
A redirect 302 is a code that tells visitors of a specific URL that the page has been moved temporarily, directing them directly to the new location.
In other words, redirect 302 is activated when Google robots or other search engines request to load a specific page. At that moment, thanks to this redirection, the server returns an automatic response indicating a new URL.
In this way errors and annoyances are avoided both to search engines and users, guaranteeing smooth navigation.
For More details Refer this Article.
This question was asked a long ago, while the RFC 2616 was still hanging around. Some answers to this question are based in such document, which is no longer relevant nowadays. Quoting Mark Nottingham who, at the time of writing, co-chairs the IETF HTTP and QUIC Working Groups:
Don’t use RFC2616. Delete it from your hard drives, bookmarks, and burn (or responsibly recycle) any copies that are printed out.
The old RFC 2616 has been supplanted by the following documents that, together, define the HTTP/1.1 protocol:
So I aim to provide an answer based in the RFC 7231 which is the current reference for HTTP/1.1 status codes.
302
status codeA response with 302 is a common way of performing URL redirection. Along with the 302 status code, the response should include a Location header with a different URI. Such header will be parsed by the user agent and then perform the redirection:
Web browsers may change from POST to GET in the subsequent request. If this behavior is undesired, the 307 (Temporary Redirect) status code can be used instead.
This is how the 302 status code is defined in the RFC 7231:
6.4.3. 302 Found
The
302
(Found) status code indicates that the target resource resides temporarily under a different URI. Since the redirection might be altered on occasion, the client ought to continue to use the effective request URI for future requests.The server SHOULD generate a
Location
header field in the response containing a URI reference for the different URI. The user agent MAY use theLocation
field value for automatic redirection. The server's response payload usually contains a short hypertext note with a hyperlink to the different URI(s).Note: For historical reasons, a user agent MAY change the request method from
POST
toGET
for the subsequent request. If this behavior is undesired, the307
(Temporary Redirect) status code can be used instead.
According to MDN web docs from Mozilla, a typical use case for 302 is:
The Web page is temporarily not available for reasons that have not been unforeseen. That way, search engines don't update their links.
The RFC 7231 defines the following status codes for redirection:
The RFC 7238 was created to define another status code for redirection:
Refer to this answer for further details.
According to RFC 1945/Hypertext Transfer Protocol - HTTP / 1.0:
302 Moved Temporarily
The requested resource resides temporarily under a different URL.
Since the redirection may be altered on occasion, the client should
continue to use the Request-URI for future requests.
The URL must be given by the Location field in the response. Unless
it was a HEAD request, the Entity-Body of the response should
contain a short note with a hyperlink to the new URI(s).
If the 302 status code is received in response to a request using
the POST method, the user agent must not automatically redirect the
request unless it can be confirmed by the user, since this might
change the conditions under which the request was issued.
Note: When automatically redirecting a POST request after
receiving a 302 status code, some existing user agents will
erroneously change it into a GET request.
In the term of SEO , 301 and 302 both are good it is depend on situation,
If only one version can be returned (i.e., the other redirects to it), that’s great! This behavior is beneficial because it reduces duplicate content. In the particular case of redirects to trailing slash URLs, our search results will likely show the version of the URL with the 200 response code (most often the trailing slash URL) -- regardless of whether the redirect was a 301 or 302.
For anyone who might be curious about the naming, I'm just going to add that it's probably called "Found" because the main resource(e.g., a private web page) the user intends to receive is not available at that moment(e.g., the user has not proved their identity yet), so instead the server has found a new resource that the user can receive(which is a login page in the most common use case).
Also it's "getting lost and found" in the hide-and-seek manner, meaning a lost resource under a 302 status is only lost temporarily, it is not supposed to be lost forever(unless a player has some bad intentions;)).