HTTPQUERY
中文

302 Found

Usage

When the 302 Found status code is received, the client understands the requested resource has temporarily moved. A second request retrieves the resource at the new location. This is simpler than a 301 because the client is not expected to update internal links.

Common triggers for 302 responses include HTTP-to-HTTPS upgrades (often better served by 301), URL normalization (trailing slash), A/B testing, geolocation-based content routing, and temporary maintenance redirects.

Cacheability

A 302 response is not cacheable by default. Unlike 301 and 308, a 302 requires explicit Cache-Control or Expires headers to be stored by caches.

Example

The client requests a resource temporarily moved. The server indicates the new location and supplies a relevant message for client-side display.

Request

GET /news.html HTTP/1.1
Host: example.com

Response

HTTP/1.1 302 Found
Location: http://example.com/testing/news.html
Content-Type: text/html
Content-Length: 167

<h1>The Newsfeed has moved</h1>
<body>
The site is under development and the newsfeed has
temporarily moved to
<a href=/testing/news.html>here</a>.
</body>

Code references

.NET

HttpStatusCode.Found

Rust

http::StatusCode::FOUND

Rails

:found

Go

http.StatusFound

Symfony

Response::HTTP_FOUND

Python3.5+

http.HTTPStatus.FOUND

Java

java.net.HttpURLConnection.HTTP_MOVED_TEMP

Apache HttpComponents Core

org.apache.hc.core5.http.HttpStatus.SC_MOVED_TEMPORARILY

Angular

@angular/common/http/HttpStatusCode.Found