我正在调试一个HTTP 301永久重定向的问题。经过快速测试,Safari似乎在重新启动时清除了它的301缓存,但Firefox却没有。

IE、Chrome、Firefox和Safari什么时候清空它们的301缓存?

For example, if I want to redirect 1.example to 2.example, but I accidentally set it to redirect to 3.example, that is a problem. I can correct the mistake, but anyone who has visited 1.example in the meantime will have cached the incorrect redirect to 3.example, and so they will not be able to reach either 1.example or 2.example until their cache is cleared. Upon investigation, I find that there were no Cache-Control and Expires headers set. The headers for the incorrect 301 response would have been like this:

HTTP/1.1 301 Moved Permanently
Date: Wed, 27 Feb 2013 12:05:53 GMT
Server: Apache/2.2.21 (Unix) DAV/2 PHP/5.3.8
X-Powered-By: PHP/5.3.8
Location: http://3.example/
Content-Type: text/html

我自己的测试表明:

IE7, IE8, Android 2.3.4完全不缓存。 Firefox 18.0.2、Safari 5.1.7(适用于Windows 7)和Opera 12.14都有缓存,并在重新启动浏览器时清除缓存。 IE10和Chrome 25缓存,但不清楚浏览器重启,所以他们什么时候会清除?


当前回答

Chrome 71

要清除永久重定向,转到chrome://settings/clearBrowserData,从那里只清除“缓存的图像和文件”清除重定向。

Chrome 48 - 70

转到chrome://net-internals。在顶部红色状态栏右侧,点击向下箭头▼打开下拉菜单,在“工具”组下,选择“清空缓存”。

在48版中,这是唯一对我有效的清除缓存301的方法。

其他回答

让用户在该url上提交一个post表单,缓存的重定向消失了:)

<body onload="document.forms[0].submit()">
<form action="https://forum.pirati.cz/unreadposts.html" method="post">
    <input type="submit" value="fix" />
</form>
</body>

要禁用重定向,请将此代码放在重定向站点的索引文件中

<script>
    fetch('https://www.example.com', {method: 'post'}).then(() => {})
</script>

有一个非常简单的方法来删除浏览器缓存http重定向,如301,307等。

你可以在chrome浏览器的开发控制台打开网络面板。选择网络调用。右键单击它,然后单击“清除浏览器缓存”以删除缓存的重定向。

Chrome 71

要清除永久重定向,转到chrome://settings/clearBrowserData,从那里只清除“缓存的图像和文件”清除重定向。

Chrome 48 - 70

转到chrome://net-internals。在顶部红色状态栏右侧,点击向下箭头▼打开下拉菜单,在“工具”组下,选择“清空缓存”。

在48版中,这是唯一对我有效的清除缓存301的方法。

移动Chrome(93版)的一个技巧:尝试在“桌面网站”模式下打开url -这在我的情况下删除了一个永久缓存重定向。