某天访问某个不存在的网站,突然发现被重定向到百度去了。

首先打开全局代理,试了下还是重定向到百度去。打开调试重新进入,可见

  • General
Request URL: http://XX.XXX.com/
Request Method: GET
Status Code: 301 Moved Permanently (from disk cache)
Remote Address: 104.27.141.68:80
Referrer Policy: no-referrer-when-downgrade
  • Respond Headers
HTTP/1.1 301 Moved Permanently
Date: Mon, 04 Mar 2019 14:40:52 GMT
Content-Type: text/html
Location: http://baidu.com
Server: cloudflare
CF-RAY: 4b249b974c729330-SJC

301 代表永久重定向

This indefinite caching is only the default caching by these browsers in the absence of Cache-Control headers. The logic is that you are specifying a "permanent" redirect and not giving them any other caching instructions, so they'll treat it as if you wanted it indefinitely cached.

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

如果header没有缓存控制,那么浏览器将按照其意思,永久自动重定向到另一个地址,不再尝试从源地址发送请求。

看来就是这个原因,解决方法当然可以清空缓存,但是比较粗暴,其实有更好的办法:

  • opera、chrome

DevTools-> Settings -> Preferences -> Network 勾上Disable cache(while DevTools is open)

然后重新进入网站即可

https://salferrarello.com/chrome-clear-redirect-cache/

  • firefox

Locate the site you are redirected from in the History sidebar. Right-click it and select "Forget about this site".

从历史记录点击忘记这个网站就行了

https://superuser.com/questions/467999/clear-301-redirect-cache-in-firefox