Using 301/303/307 redirects for dynamic short urls
Asked Answered
B

2

6

We're implementing a short url service where the redirection target will be changing daily. The urls will be accessed by mobile devices and will always be GET requests. I'm trying to understand which is the best 300-type redirect for the job.

AFAIK most url shortening services use 301 redirects (Moved permanently). However, according to the specs, the 303 (See other) and 307 (Moved temporarily) redirects seems like they were designed for our case...

  • Are 303/307 as well supported as 301? The specs say they were only implemented in HTTP 1.1- what limitations does that spell?
  • Are there any actual caching or performance implications of choosing 301 vs 303/307.
  • For GET requests, is there any reason to pick 303 vs 307?
  • Is there any reason to use 302 redirects?
  • Any other things to consider?
Bedspring answered 26/1, 2012 at 0:26 Comment(0)
C
5

Are 303/307 as well supported as 301? The specs say they were only implemented in HTTP 1.1- what limitations does that spell?

Yes/None.

Are there any actual caching or performance implications of choosing 301 vs 303/307.

I don't think so.

For GET requests, is there any reason to pick 303 vs 307?

303 has semantics different than 307. If the requested resource is "somewhere else", 303 is not the right answer.

Is there any reason to use 302 redirects?

Not really, as far as I can tell. It has the same semantics as 307, but the UA might rewrite a POST request to GET.

Any other things to consider?

See http://greenbytes.de/tech/webdav/draft-ietf-httpbis-p2-semantics-18.html#status.3xx

Cinerama answered 26/1, 2012 at 8:37 Comment(2)
thanks. So it seems the only practical implications of whether to choose 301 vs 307 is how page rank is transferred- Would you agree with that?Bedspring
Yarin - hopefully they are treated the same. But how would I know?Cinerama
P
0

The reason that url shortening service use 301 (permanent) is:

  • It does not hold the page rank of destination url.
  • The destination url does not change (once you tell bit.ly/url1 redirects to example.com/url1, you can not modify it to redirect to example.com/url2).

All 302, 303 and 307 are temporary redirects and simply do not do the job. Except that if you want to change the destination url, you could use 302. E.g. example.com/contact redirects to example.com/temp/contact but you intend to replace the latter by example.com/v2/contact later.

Perry answered 26/1, 2012 at 8:48 Comment(2)
jcisio- you're answer is unclear. "All 302, 303 and 307 are temporary redirects and simply do not do the job" - Do not do what job? They each perform a redirect, so what job are you referring to?Bedspring
"Job" is a URL shortening service that you're talking about. Such a service is not a simple URL redirect, there are constraints. Which contraints? They're in my answer.Perry

© 2022 - 2024 — McMap. All rights reserved.