views:

320

answers:

5

Is the client supposed to behave differently? How?

+2  A: 

301 is that the requested resource has been assigned a new permanent URI and any future references to this resource SHOULD be done using one of the returned URIs. 302 is that he requested resource resides temporarily under a different URI. Since the redirection may be altered on occasion, the client SHOULD continue to use the Request-URI for future requests. This response is only cachable if indicated by a Cache-Control or Expires header field.

Peter Lee
+12  A: 

Status 301 means that the resource (page) is moved permanently to a new location. The client/browser should not attempt to request the original location but use the new location from now on.

Status 302 means that the resource is temporarily located somewhere else, and the client/browser should continue requesting the original url.

Philippe Leybaert
+1 for being simple and clear and not just reiterating the RFC
David Zaslavsky
Thank you. Does this mean that if I use a 301 (permanent) redirect, the client can decide to never again retrieve the old location and instead always use directly the new URL?
flybywire
Exactly! In fact, according to the specs, the client SHOULD always go to the new location.
Philippe Leybaert
+3  A: 

See Peter Lee's answer.

Mostly 301 vs 302 is important for indexing in search engines as their crawlers take this in account and transfer pagerank when using 301.

Residuum
+2  A: 

RFC 2616 - HTTP Status Codes

I could repeat everything in there, but it states it quite clearly ;)

Tiemen
A: 

Which is better for SEO, a 301 or 302

Jen