Should we be using 302 or 307 for temporary HTTP redirects?
As of HTTP 1.1, the response status code 307 became available for ‘Temporary Redirects’. But should we be using them instead of 302?
HTTP Code 302: “Found”
The 302 response code indicates that requested address has been temporarily removed. The browser will redirect to the address provided in the “Location” portion of the header, however Search Engines will not update the address in their result listings. 302s exclaim that the material has been successfully “Found” in their response to agents.
A caveat of the 302 response, is the response method. Even if the method is set explicitly not to change on a redirect, not all user-agents obey. It is safest to use 302 redirects for GET or HEAD methods.
This is an ideal situation for a temporary redirect in SEO situations where the SERP (Google, Bing….) should retain the original URL, but the browser should redirect to the new location.
Unfortunately, 302 redirects become an issue in situations where a POST or any non-GET or HEAD method is attempting to redirect to a location that requires the original method be present. Use caution when using 302 redirects within form logic, but feel free to use it for all of your basic “content has moved elsewhere” needs.
HTTP Code 307: “Temporary Redirect”
The 307 redirect’s “Temporary Redirect” description may seem like a sign of intended usage, but this response is a bit more nuanced upon further inspection.
307 status response codes indicate that the requested resource has been temporarily relocated to the URL given by the “Location” header (just like 302s). Unlike 302s, the original method is always preserved in the process.
Sounds great, right? You use a 307, and don’t need to worry about all the GET, POST, HEAD mumbo jumbo. Might as well slap those 307s on everything just to be safe… right?
Here’s the problem — SERPs don’t typically recognize 307 redirects as an indicator they should keep the existing address. Buh-bye link juice.
Which one should I use?
Use 302 redirects when you want to tell SERPs like Google that you’ve temporarily moved some content, and that it’ll eventually return to the original address.
Use 307 redirects when you need to preserve the method, such as a POST within advanced form logic that relies on it.
Want to work with us? Visit us at https://dodgyco.de or send your project info, timeline, and budget to email@example.com