Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

切换hosts后,chrome刷新页面不能立即生效 #254

Open
jixiangqd opened this issue Oct 20, 2017 · 8 comments
Open

切换hosts后,chrome刷新页面不能立即生效 #254

jixiangqd opened this issue Oct 20, 2017 · 8 comments

Comments

@jixiangqd
Copy link

jixiangqd commented Oct 20, 2017

操作系统

mscOS 10.12.6 (16G29)

SwitchHosts! 版本

5287

问题描述

切换完后刷新,发现还能访问切换前版本的页面。不能立即生效,经查询是KeepAlive设置的问题。iHosts通过重启网络解决该问题,能否也使用同样的方式处理一下?

参考资料:http://www.cnblogs.com/hustskyking/p/hosts-modify.html

重现步骤

先访问一个有KeepAlive设置的网站,切换完后刷新,页面不能请求到另一个版本的页面。

@jixiangqd
Copy link
Author

实测可以在mac下这么操作:

for i in `ifconfig | grep ": flags=" | sed -E 's/(.*): .*/\1/g'`;do sudo ifconfig $i down;sudo ifconfig $i up;done

oldj added a commit that referenced this issue Oct 20, 2017
@oldj
Copy link
Owner

oldj commented Oct 20, 2017

这个问题之前与 iHost 的作者交流过,代码中也有重启网络的操作,但后来这个操作似乎失效了。

感谢你提供的方法,初步测试有效。develop 分支的代码已更新,我会再测试一下。

@ElfSundae
Copy link
Contributor

我觉得一切换 hosts 就重启网络非常不合适。不是所有网络任务都有断线重连,比如用户正在用命令行下载东西。用户的网络连接也不一定都能自动连接,比如网络连接授权、代理等。
我现在是在 chrome://net-internals/#dns 里清空DNS缓存,如果只是针对 Chrome ,可能自动清空 Chrome 的 DNS 缓存要比重启网络好一点。

现在不是有自定义命令么,如果用户需要每次切换 hosts 都重启网络可以把这行代码加到自定义命令里。readme 或者 自定义命令 界面也可以给个提示。

@oldj
Copy link
Owner

oldj commented Oct 24, 2017

是的,我也有这个顾虑,所以暂时没有合并到 master,在考虑是否有更合适的方式。

放到自定义命令中似乎是个不错的选择。

@wangjianio
Copy link

可否加个选项,决定切换 host 时是否立即刷新缓存?

@nyer
Copy link

nyer commented Dec 25, 2019

chrome启动时候添加参数--enable-net-benchmarking,然后设置switchhosts自定义命令 执行cports kill掉chrome的链接。
亲测成功,屡试不爽。

@tibic
Copy link

tibic commented Jul 31, 2020

设置switchhosts自定义命令 执行cports kill掉chrome的链接,这个怎么做?

@jixiangqd
Copy link
Author

设置switchhosts自定义命令 执行cports kill掉chrome的链接,这个怎么做?

这个好像只在windows有效,mac没找到等价工具可以杀连接

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants