What's the difference between a 302 and a 307 redirect?

Zach Hirsch picture Zach Hirsch · Jan 15, 2010 · Viewed 147.3k times · Source

What's the difference between a 302 FOUND and a 307 TEMPORARY REDIRECT HTTP response?

The W3 spec seems to indicate that they're both used for temporary redirects, and neither can be cached unless the response specifically allows it.

Answer

Christopher Orr picture Christopher Orr · Jan 15, 2010

307 came about because user agents adopted as a de facto behaviour to take POST requests that receive a 302 response and send a GET request to the Location response header.

That is the incorrect behaviour — only a 303 should cause a POST to turn into a GET. User agents should (but don't) stick with the POST method when requesting the new URL if the original POST request returned a 302.

307 was introduced to allow servers to make it clear to the user agent that a method change should not be made by the client when following the Location response header.