301 vs 302 redirects for system design interviews, explained
Design a URL shortener and you reach the one line the whole system exists for: a user hits short.ly/abc, your service looks up the long URL, and sends back a redirect to it. Then the interviewer asks the question that separates a recited answer from an understood one — 301 or 302? A 301 is a permanent redirect and a 302 is a temporary one, and at first that sounds like a trivia question about HTTP status codes. It is not: the choice changes whether the browser caches the redirect, whether search engines pass SEO credit to the destination, and — the part that actually decides it — whether every future click still flows through your server so you can count it. It is a classic system design interview concept because one status-code digit quietly trades analytics for performance.
The reason it comes up is that a redirect is the URL shortener's entire hot path, and 301 vs 302 is a real engineering decision disguised as HTTP minutiae. A permanent redirect tells the browser "remember this and go straight to the target next time," which is fast and SEO-friendly but means you never see the repeat clicks. A temporary redirect tells the browser "ask me again every time," which keeps every click flowing through your service — essential if click analytics are a feature — at the cost of more load. This guide walks what a strong candidate names out loud: what 301 and 302 mean, how they differ on caching and SEO, the analytics-vs-load tradeoff in a URL shortener, and the other redirect codes worth knowing.
Why 301 vs 302 comes up in system design interviews
The 301-vs-302 question rarely stands alone; it is the sharp follow-up inside a URL-shortener design (and anywhere you redirect — a renamed page, an A/B split, a maintenance bounce). You draw the redirect on the whiteboard, and the interviewer asks which status code and why — and then, if you answer "301, permanent," they ask how you are going to count clicks when the browser never comes back. It is a favourite probe because the status code is easy to name and the consequence — caching, SEO, and the lost analytics — is where the real understanding lives.
The interviewer rarely lets "we send a redirect to the long URL" stand on its own. "You return a 301 so it's fast and cached. Great — now the product team wants a dashboard of clicks per link. The browser cached your redirect and goes straight to the destination from now on, so your server never sees those clicks. What changed, and what would you return instead?" That question — the analytics cost of caching the redirect — is the one a memorised "301 is permanent, 302 is temporary" answer can never survive.
The rounds on Zynter are modelled on how the loop runs, not scraped from any candidate's recall. What matters for prep is the shape: you name a status code, and the next sentence asks about caching, SEO, or the click you can no longer count.
What the interviewer is really testing
A 301-vs-302 answer is read on the same four dimensions as any design decision. Problem solving — did you tie the status code to a product requirement (analytics vs performance), or recite the definition? Communication — can you say in one sentence why a 301 is cached and a 302 is not, and what that does to your traffic? Technical execution — do you know 301 passes SEO equity and that a 302 keeps every click on your server? Time management — did you spend your words on the tradeoff, not on listing every 3xx code? Reading this guide teaches the codes; it does not teach you to defend the choice while someone asks for a click dashboard.
What 301 and 302 actually mean
Both are HTTP 3xx redirection responses: the server replies with a status code and a Location header naming the URL the client should go to instead, and the browser automatically follows it. The difference is the promise the status code makes about how long the redirect lasts:
- 301 Moved Permanently — "this resource has moved for good; use the new URL from now on." It signals permanence, so clients and search engines are free to remember it: browsers cache it and go straight to the target on future requests, and search engines update their index to the destination and transfer the page's ranking credit to it.
- 302 Found (temporary redirect) — "the resource is temporarily somewhere else; keep using the original URL." It signals impermanence, so clients do not cache it by default: the browser asks your server again every time, and search engines keep the original URL in their index.
The sentence that scores: both send a Location header the browser follows; a 301 says the move is permanent so it gets cached and the SEO credit moves to the target, while a 302 says it's temporary so it is not cached and every request comes back to you. The one-word difference — permanent vs temporary — is what drives every downstream behaviour, so lead with that and the consequences follow.
The real difference: caching and SEO
The definitions are the easy half; the behaviour they cause is what the interview is about. Two consequences follow directly from "permanent vs temporary":
- Caching. Because a 301 is permanent, browsers (and intermediaries) cache it, often aggressively and for a long time — so after the first response, the client goes directly to the destination and your server is never contacted again for that URL. A 302 is temporary, so it is not cached by default, and the client re-requests your URL every time, getting the redirect fresh.
- SEO / link equity. Search engines treat a 301 as "the content lives at the new URL now," so they move the ranking signals (the "link equity" or "link juice") to the destination and index that URL. A 302 tells them "the original is still the real home," so they keep the original indexed and do not pass the ranking credit on. This is why a genuine, permanent site migration should always be a 301 — a 302 would strand your SEO on the old URL.
The sentence that scores: a 301 is cached and passes SEO credit to the target — perfect for a permanent move — while a 302 is not cached and keeps the original URL indexed, which matters the moment you care about search ranking or about whether traffic keeps hitting your server. Note the common trap: using a 302 for what is really a permanent move (so the destination never gains the ranking it should), or a 301 for a temporary one (so browsers cache a redirect you cannot easily take back).
System Design
HLD · Core concept
Explain the caching and SEO difference out loud
The URL shortener tradeoff: analytics vs load
This is the decision the whole topic is built around, and it is why 301 vs 302 is a design question, not trivia. In a URL shortener, the redirect is the product, and the status code decides whether you can measure it:
- Return a 301 (permanent): the browser caches it, so after the first click, repeat visits go straight to the destination and never touch your server. The upsides are real — less load on your service, a faster second click for the user, and the SEO credit flowing to the destination. The cost is the one the interviewer is fishing for: you lose per-click analytics, because your server only ever sees the first request for each browser. If you later change where the short link points, cached browsers keep going to the old target.
- Return a 302 (temporary): the browser does not cache it, so every single click comes back through your service. That is exactly what you want if click analytics are a feature — counts, geography, referrers, A/B tests — and it lets you change the destination at any time and have it take effect immediately. The cost is more load (every click is a request you must serve) and the redirect latency on every visit.
The sentence that scores: in a URL shortener, a 301 trades analytics for performance — it's cached, so clicks skip your server and you can't count them — while a 302 trades performance for control — every click hits your server, so you get full analytics and can update the destination live. If click tracking is a product requirement, you lean 302; if raw speed and SEO matter more and you don't need per-click data, 301. This is the sentence that turns a status-code question into a system-design answer.
System Design
HLD · Core concept
Defend 301 vs 302 for a URL shortener out loud
Other redirect codes and pitfalls
301 and 302 are the headline pair, but a complete answer knows the neighbours and the traps:
-
307 Temporary Redirect and 308 Permanent Redirect — the modern, stricter versions of 302 and 301 that guarantee the HTTP method and body are preserved. Historically, some clients would change a
POSTinto aGETwhen following a 301 or 302; 307 (temporary) and 308 (permanent) forbid that, so they are the safe choice when the request is not a plainGET. -
303 See Other — explicitly tells the client to follow the redirect with a
GET, commonly used after a form submission (the post/redirect/get pattern) so a refresh does not re-submit. - Redirect chains and loops — each redirect is an extra round trip, so a chain (A → B → C) hurts latency and SEO, and a misconfigured pair can create an infinite loop; keep redirects to a single hop.
- The caching caveat — because a 301 can be cached for a very long time, it is hard to undo; if there is any chance the mapping will change, a 302 (or a 301 with a deliberate cache policy) is safer.
The point to state plainly: 301/302 are the permanent/temporary pair you reach for by default, 308/307 are their method-preserving equivalents for non-GET requests, and the real-world gotcha is that a 301 is sticky — cached hard and slow to take back.
How to talk about 301 vs 302 in an interview
The probes from every section rhyme. Master these five and you can defend a redirect choice in any design, not just this checklist.
- "301 or 302 — what's the difference?" → 301 is a permanent redirect, cached by browsers and passing SEO credit to the destination; 302 is temporary, not cached, keeping the original URL indexed and routing every request back to you. (communication)
- "Which do you use in a URL shortener, and why?" → It depends on analytics: 302 if per-click tracking is a feature, because every click hits your server; 301 if speed and SEO matter more and you don't need per-click data. (problem solving)
- "You used a 301 and now can't count clicks — what happened?" → The browser cached the permanent redirect and goes straight to the destination, so your server never sees repeat clicks; switch to 302 to route every click through you. (technical execution)
- "Which is better for SEO?" → 301, for a genuine permanent move, because it transfers the ranking credit to the new URL; a 302 leaves the ranking on the original. (communication)
- "Any gotchas with 301?" → It is cached aggressively and hard to undo, and old clients could change POST to GET — use 308/307 to preserve the method, and avoid 301 for mappings that might change. (technical execution)
Each maps to a debrief dimension. Reading them teaches the answers; it does not teach you to deliver them while someone asks for a click dashboard — that only comes from saying them out loud.
How to prepare: a short plan
You do not need a new topic for every design. You need the redirect distinction automatic, so when a design sends a redirect you reach for the right code and can defend it.
- Day 1: Learn the definitions tied to their behaviour — 301 permanent (cached, SEO moves) vs 302 temporary (not cached, SEO stays) — until you can state both consequences from the one-word difference.
- Day 2: Drill the URL-shortener tradeoff — analytics vs load — and the method-preserving 307/308. This is where the follow-ups live.
- Day 3: Place the choice inside a URL shortener design: pick a code based on whether click analytics are required, and name the caching gotcha. Then do it out loud, timed, with someone asking how you'd count clicks.
This explainer feeds the broader Top 25 system design interview questions — the 301-vs-302 choice is the classic follow-up in a URL shortener round, so getting it automatic pays off there and in any redirect decision.
Frequently asked questions
What is the difference between a 301 and a 302 redirect?
Both are HTTP redirection responses that carry a Location header the browser follows, but they make opposite promises about permanence. A 301 Moved Permanently says the resource has moved for good, so clients and search engines may remember it: browsers cache the redirect and go straight to the destination on future requests, and search engines move their index entry and ranking credit to the new URL. A 302 Found says the move is only temporary, so browsers do not cache it and re-request your server every time, and search engines keep the original URL indexed. In short, 301 is cached and transfers SEO equity, while 302 is not cached and keeps traffic and ranking on the original URL.
Which redirect should a URL shortener use?
It depends on whether click analytics are a product requirement. A 301 is permanent and cached, so after the first click a browser goes straight to the destination and never contacts your service again — this means less load and faster repeat clicks and SEO credit flowing to the destination, but you lose per-click analytics and cannot easily change where the link points because browsers have cached the old target. A 302 is temporary and not cached, so every click routes back through your service, which lets you count every click, capture geography and referrers, run A/B tests, and change the destination live — at the cost of more load and a redirect on every visit. So if tracking clicks is a feature you lean toward 302; if raw performance and SEO matter more and per-click data is not needed, 301 is fine.
Why does a 301 affect SEO but a 302 doesn't?
Because search engines interpret the permanence signal. A 301 tells them the content has permanently moved, so they update their index to the new URL and transfer the accumulated ranking signals — the "link equity" — to the destination, which is exactly what you want when genuinely moving a page or a whole site. A 302 tells them the move is only temporary and the original URL is still the real home, so they keep the original indexed and do not pass the ranking credit to the target. This is why using a 302 for a permanent migration is a common and costly mistake: the destination never inherits the ranking it should, and the old URL keeps the authority even though the content lives elsewhere.
What is the difference between 302, 307, and 308?
They differ on permanence and on whether the HTTP method is preserved. A 302 Found is a temporary redirect, but historically some clients would change a POST into a GET when following it, which could silently alter the request. 307 Temporary Redirect is the modern, stricter temporary redirect that guarantees the method and body are preserved, so a POST stays a POST. 308 Permanent Redirect is the permanent equivalent that also preserves the method — essentially a 301 that will not downgrade a POST to a GET. So for plain page redirects 301 and 302 are fine, but when the request might be a POST or carry a body, use 308 for a permanent move and 307 for a temporary one to avoid the method changing underneath you.
How do I practise a system design interview out loud?
Reading about redirects is not the same as defending a status-code choice while an interviewer asks for a click dashboard. On Zynter, the HLD track runs live voice rounds modelled on how real system design loops run — you talk through a design (like a URL shortener) on a shared canvas, and a voice interviewer follows up one question at a time ("301 or 302, and why?", "now count the clicks", "which is better for SEO?"), then gives you a debrief on problem solving, communication, technical execution and time management. The score is a practice signal, not a hiring decision.
Practise it on Zynter
You can say "301 is permanent, 302 is temporary." The round is won on the analytics-vs-load tradeoff.
Pick the URL shortener round, draw the redirect on the canvas, and defend your status-code choice out loud to a voice interviewer that keeps asking "301 or 302, and why?" and "the browser cached it — how do you count clicks now?" — then read the debrief. Zynter.ai is on-demand mock interviews modelled on real company loops, with 150+ rounds across 20 companies including the HLD system design track (Sep 2026).
Practise an HLD system design round →
Browse all interview tracks




Top comments (0)