Try
↑ ↓ move↵ openesc close

Interview prep / URL shortener

Senior · URL shortener · System design interview question

Compare a 301 and a 302 redirect for a short link service.

Sketch your own answer first, then compare it with the one below.

A strong answer

A 301 says the move is permanent. Browsers and caches may remember it and skip the server next time. That cuts load and latency.

A 302 says the move is temporary, so each click returns to the server. That keeps click counts, allows a link to expire or change its target, and costs more traffic.

If analytics or edits matter, use a 302, perhaps with a short cache lifetime. If links are permanent and cost matters most, a 301 works. The trade-off is load against control.

Sources

Learn it by running it

The design a url shortener lesson explains the mechanism behind this question, and its lab lets you change the parameters and watch the effect.

Your progress is saved in this browser. Sign in to keep it on every device. Privacy · Terms