301, 302, 307, 308: HTTP redirects, explained properly
Every redirect on the web is a tiny negotiation. A server says "not here — there," and the three-digit code it uses determines how seriously the browser takes that statement: whether to remember it forever, whether to repeat the original request exactly, and what search engines should conclude about the old URL.
The permanent family: 301 and 308
A 301 Moved Permanently means the old URL is retired. Browsers cache the mapping aggressively — sometimes until the cache is manually cleared — and search engines transfer the old URL's standing to the new one. That makes 301 the right tool for site migrations and the wrong tool for anything that might change, because once a browser has cached a 301, it may never ask your server again.
308 Permanent Redirect is 301's stricter sibling: same permanence, but the client must preserve the request method. A POST stays a POST. Older clients following a 301 would sometimes convert a POST into a GET, which mattered for form submissions and APIs; 308 closed that loophole.
The temporary family: 302 and 307
A 302 Found says "there, for now." Browsers follow it but don't treat the move as permanent. It's the web's historical default for temporary forwarding, with the same method-changing quirk that 301 had.
307 Temporary Redirect is the modern, precise version: temporary, method-preserving, and not meant to be cached long-term. If the server's answer might be different tomorrow, 307 is the honest code to send.
Why shorteners care so much
A URL shortener's whole product is redirects, so the code choice is a product decision:
- Editable destinations need temporary codes. If a shortener answered with 301s, browsers would cache the mapping — and when a customer later pointed the link somewhere new, returning visitors would keep landing on the old destination. Temporary redirects (302/307) keep the shortener in the loop on every click.
- Counting needs the click to arrive. Aggressive caching also means the browser skips the shortener entirely on repeat visits, so clicks go uncounted. Temporary codes keep analytics truthful.
- Permanence is available when it's wanted. For links whose destination will genuinely never change, a permanent code is a fine optimization — it just has to be a deliberate choice.
This is why Shortner defaults to 307: it's the code that accurately describes what a managed short link is — a mapping the owner is allowed to change.
Spotting them in the wild
Open your browser's developer tools, watch the Network tab, and click a short link. You'll see the short URL return a 3xx with a Location header, then the browser request that location. The whole exchange is a few hundred bytes — the web's smallest useful transaction.