1

I have looked on Stack Exchange but didn't find the solution for my problem.

The problem: I have a website and want to become an SEO hero. So, I also need to choose status codes...

I know that there are approximately 2 status codes to trigger a redirect.

  • 301 - Moved Permanently
  • 302 - Moved Temporarily

The question: Which status code stays longer in the cache and how long would that be approximately?

3

there are approximately 2 status codes to trigger a redirect

More like 5 ... 301, 302, 303, 307 and 308.

See: https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#3xx_Redirection

302 - Moved Temporarily

A 302 should never be cached. Browsers do not ordinarily cache a 302. It is after all "temporary".

301 - Moved Permanently

301s are cached by default. Since this is considered a "permanent" redirect, browsers (and possibly intermediary caches) will cache a 301 "aggressively". Without additional cache control headers there is no clear rule for how long the redirect should be cached - it's browser/cache dependent. But suffice to say, it can be a "long time".

However, you should be able to send the appropriate cache control headers (ie. Cache-Control/max-age and Expires HTTP response headers) with the redirect in order to control the caching behaviour.

Reference:
https://stackoverflow.com/questions/9130422/how-long-do-browsers-cache-http-301s

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.