我们正在实现一个短网址服务,其中重定向目标每天都在变化。这些 url 将由移动设备访问,并且始终是 GET 请求。我试图了解哪个是最适合这项工作的 300 型重定向。
据我所知,大多数 url 缩短服务使用 301 重定向(永久移动)。然而,根据规范,303(查看其他)和 307(暂时移动)重定向似乎是为我们的案例设计的...
- 是否像 301 一样支持 303/307?规范说它们仅在 HTTP 1.1 中实现 - 这意味着什么限制?
- 选择 301 与 303/307 是否有任何实际的缓存或性能影响。
- 对于 GET 请求,是否有理由选择 303 和 307?
- 是否有理由使用 302 重定向?
- 还有其他需要考虑的事项吗?
最佳答案
Are 303/307 as well supported as 301? The specs say they were only implemented in HTTP 1.1- what limitations does that spell?
是/无。
Are there any actual caching or performance implications of choosing 301 vs 303/307.
我不这么认为。
For GET requests, is there any reason to pick 303 vs 307?
303 的语义不同于 307。如果请求的资源是“其他地方”,则 303 不是正确答案。
Is there any reason to use 302 redirects?
据我所知,不是真的。它具有与 307 相同的语义,但 UA 可能会将 POST 请求重写为 GET。
Any other things to consider?
参见 http://greenbytes.de/tech/webdav/draft-ietf-httpbis-p2-semantics-18.html#status.3xx
关于http - 对动态短网址使用 301/303/307 重定向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9012456/