301 vs 302: The Redirect Code That Decides Who Gets Your SEO

From a browser's perspective, a 301 and a 302 redirect are indistinguishable — same instant jump to the Location header, same nothing-visibly-different outcome, which is exactly why this is one of the easiest HTTP details to get wrong in production: nothing in normal testing tells you that you chose badly. The difference only shows up in how a search engine, or any client that caches, treats the old URL afterward.
What each one is actually claiming
301 Moved Permanently tells the caller: this resource is not coming back at this address, ever — update whatever you were using to reach it. A 302 Found says the opposite: this is temporary, keep using the original URL for next time, this particular response just happens to point somewhere else right now.
That claim is the entire difference. Both return the same status-line mechanics (a Location header, an empty or informational body), both make a browser navigate immediately, and neither one is "more correct" in general — they're correct for different situations, and the situation is about permanence, not about anything technical in the request itself.
Where it actually matters: search engines, not browsers
A user's browser doesn't care which one you send. A search engine's crawler does, and this is where getting it backwards has real, slow-to-notice consequences: on a 301, Google (and most crawlers) transfer the old URL's accumulated ranking signal to the new one and drop the old URL from the index over time — the redirect is treated as "this page moved, forward its authority." On a 302, the old URL is expected back, so the crawler keeps the original URL indexed and generally does not pass its ranking signal to the target.
The bug this produces: a site migrates a page to a new URL, someone reaches for whatever redirect their framework defaults to (302 is a common default because it's the more "cautious" choice), and months later organic traffic to that page has quietly dropped — because the old URL is still what's indexed, the new URL never inherited its authority, and nothing in the site's own uptime or error monitoring would ever flag it, since the redirect itself "worked" the entire time.
The method-and-body wrinkle
There's a second, less well-known difference that has nothing to do with SEO: per RFC 9110, a 301 or 302 response to a non-GET/HEAD request has historically been treated by most browsers as permission to change the follow-up request to GET, dropping the original body. Redirect a POST with a 301 or 302 and plenty of clients will replay it as a GET, silently losing whatever was in the request body. If you need a redirect that guarantees the method and body survive, that's what 307 Temporary Redirect and 308 Permanent Redirect are for — newer codes, added specifically to close this gap, that carry the same permanent-vs-temporary meaning as 301/302 but forbid the method-downgrade behavior.
A quick reference, since this is the part people actually need mid-decision
- Moving a page for good, want the new URL to inherit search ranking:
301 - Pointing somewhere else temporarily (A/B test, maintenance page, geo-redirect):
302 - Either of the above, but redirecting a POST/PUT/PATCH where the method must not change:
308(permanent) or307(temporary)
Testing a redirect chain without waiting for Google to notice
The actual failure mode here — choosing the wrong permanence and finding out from a traffic graph weeks later — is hard to catch because a redirect's correctness (does it point somewhere valid) and its semantics (does it claim the right kind of move) are two different questions, and only the first one shows up when you click the link yourself. A mock route set to return a 301, 302, 307, or 308 on purpose lets you verify a client — or a monitoring script asserting on the exact status code — actually distinguishes between them, rather than discovering the difference only mattered once it was already load-bearing for search traffic.
Xerat02
Building MockBase.
More from the blog

Mock vs Stub vs Spy vs Fake: The Test Double Vocabulary Nobody Agrees On
Developers use "mock" as a catch-all for anything fake in a test, which is exactly backwards from how the term was originally meant — and the actual distinctions aren't pedantry, they're about what a test can and can't tell you when it passes.

400 vs 409 vs 422: Three Ways an API Says "No"
All three mean "I'm not doing that," and all three tempt a tired developer into reaching for whichever one they remember first — but they're answering three different questions about what's actually wrong with the request.