且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

避免301重定向缓存

更新时间:2022-04-09 23:31:50

不要尝试以避免301缓存。如果您不希望任何用户代理缓存您的重定向,则只需不要使用301重定向。换句话说,301缓存将保留下来,从语义上讲,这是永久重定向,因此,如果您打算更改目标URL,则301不是正确的状态代码。另一方面,默认情况下, 307个响应未默认缓存

Don't try to avoid 301 caching. If you don't want any user agent to cache your redirect, then simply don't use a 301 redirect. In other words, 301 caching is here to stay, and semantically, it's a permanent redirect, so if you're planning to change the destination URL, 301 is not the right status code to use. On the other hand, 307 responses are not cached by default.