Urlsome

301 or 302? How short links should redirect

Why our short links answer with a 302 redirect instead of a 301, and what that means for editable links, QR codes and click counts.

A short link is a redirect: you open https://<domain>/spring-event, the server answers "the page you want is at this other address", and the browser goes there. HTTP has several ways to say that. The two that matter are 301 Moved Permanently and 302 Found.

What the difference is

  • A 301 says the move is permanent. Browsers are allowed to remember it and, the next time someone opens the same short link, go straight to the destination without asking the server again. Some browsers keep that memory for a very long time.
  • A 302 says the move is temporary. The browser asks the server every time.

Search engines also treat them differently: a 301 passes the old address's ranking to the new one. For a short link that is mostly irrelevant, because nobody wants the short URL itself to rank.

Why we use 302

Every link in this service can change after you share it:

  1. You can change the destination. A link on a printed flyer, in a bio or behind a QR code is useful precisely because it can be pointed somewhere else later. With a 301, a visitor whose browser remembered the old destination would keep going there.
  2. A link can stop. You can delete it, and a link nobody clicked for 12 months retires (it answers 410). A remembered 301 would keep redirecting after the link is gone.
  3. Every click should be counted. A browser that follows a remembered 301 never reaches us, so repeat visits would silently disappear from your statistics.

A 302 avoids all three, at the cost of one quick request to our server per click. We also send Cache-Control: private, max-age=0, so shared caches do not keep the redirect either.

What we count as a click

Each GET of the short link that we redirect. For each one we add one to a counter for that link, that day, the visitor's country, the domain of the referring page and the kind of device. We do not store IP addresses, full referrer URLs or cookies. HEAD requests, which link previews and uptime monitors often send, get the same redirect but are not counted.