大网数据广告活动
网站运营与故障问答

Which is longer cached by SE robots or browsers, redirect 301 or 302

· 52CE 我爱测

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 cod…

问题原文

原帖链接 · Koen Hollander · CC BY-SA 3.0

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?

已采纳解答

原帖链接 · MrWhite · CC BY-SA 3.0

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

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Webmasters Stack Exchange
适用范围
以原帖系统、软件版本与发布日期为准(2017-06-10)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。