Skip to content

What's the difference?

301vs302

Both send the browser to another address. Watch who answers the first request.

  1. 301Remembered. The CDN has stored the redirect and answers by itself. Your servers never hear about the old address.
  2. 302Asked every time. The request goes all the way to the app, which decides again where to send it.

How to tell them apart in 10 seconds

What it means

301
The address changed for good
302
The address is different for now

Next time, the client

301
May go straight to the new address
302
Asks the original address again

Cached?

301
Yes by default, with no built-in expiry
302
Only if the response says so

Who typically sends it

301
Proxy or CDN, for site-wide rules
302
The app, for decisions per request

Easy to undo?

301
No. Clients that stored it keep following it
302
Yes. Remove it and the next request sees the change

POST stays POST?

301
Not guaranteed. Use 308 for that
302
Not guaranteed. Use 307 for that

In short

301 vs 302: the difference

301: moved for good, and clients may remember it. 302: somewhere else for now, so ask again next time.

Both codes tell the client to go to the address in the Location header, and the browser follows either one immediately. The difference is what the client should do next time. A 301 Moved Permanently says the old address is finished: use the new one from now on. It is cacheable by default, so browsers and CDNs store it and stop asking the origin about the old address. A 302 Found says the detour is temporary: keep using the original address, because the answer may change. It is not stored unless the response explicitly allows it. That makes 302 the safe choice while a redirect might still be undone, and 301 the right one once a move is final. Both allow clients to turn a POST into a GET; 307 and 308 are the versions that do not.

Your turn

Which one is this?

Which one should this be? A shop sends visitors from /sale to /summer-sale for two weeks. After that, /sale must show a different page.

Each code in depth

Lesson: 301 vs 302

Questions

What is the difference between 301 and 302?
A 301 is a permanent move: clients should use the new address from now on and may cache the redirect. A 302 is temporary: clients follow it once and keep using the original address.
Which redirect is better for SEO, 301 or 302?
Use the one that is true. A 301 tells search engines the new address replaces the old one. A 302 tells them the old address is still the one to keep.
Can I undo a 301 redirect?
On the server, yes. But browsers and caches that already stored it can keep following it, because a 301 has no built-in expiry.

Sources: RFC 9110: 301 Moved Permanently (section 15.4.2) ↗ · RFC 9110: 302 Found (section 15.4.3) ↗ · Report a problem

Diagrams are our own simulations. All wording is original and paraphrases the linked sources.

Practise this in the DNS / HTTP track

Two-minute animated lessons, then boss fights from real outages. Free, no account needed.

Start the track