HTTP - 301 vs 302 redirection - when to use which one?

5 points
Created by:

In this short article we want to explain when to use 301 or 302 location redirection status with HTTP requests.

Location redirection with 301 status

It should be used when we want to replace permanentally some URL and we want to tell to search engines  that URL is depricated and was replaced by new one.

Note: many browsers cache responces with 301 status, that causes the web browser doesn't request server again opening directly new one link - it can lead to reopen URL from previous request.

Browser request example:

GET /path-to-old-file-name.html HTTP/1.1

Server response example:

HTTP/1.1 301 Moved Permanently

Location redirection with 302 status

It should be used when we want to:

  • have many links to same resource and all of them are important too (it is like shortcut of some link that)
  • be sure that web browser requests server always before redirection occures to get most current redirection URL becouse it can be changed by server in anytime.

Browser request example:

GET /index.php HTTP/1.1

Server response example: 

HTTP/1.1 302 Found

Advices (Browser Caching of 301 Redirects)

  • Clear your browser cache each and every time you make a change to a 301 redirect,
  • Never put a 301 (permanent) redirect in place unless it is truly permanent!
  • Always implement 302 (temporary) redirects first, then change them to 301 (permanent) redirects once you’ve tested them!


Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.


Native Advertising
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂