Using 301/303/307 redirects for dynamic short urls

5.2k views Asked by At

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?
2

There are 2 answers

2
Julian Reschke On BEST ANSWER

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

2
jcisio On

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.