清理 Chrome DNS Cache

版权声明:本文为博主原创文章,未经博主允许不得转载。转载请在文章结尾显眼处附带博主文章地址。 https://blog.csdn.net/qq_27559331/article/details/89886059

通常浏览器为了加快网页请求(减少DNS查询过程中的耗时),会在程序中添加一层DNS缓存。这层缓存的优先级是高于系统DNS缓存。修改Hosts文件后,一般在2~10分钟(ttf)之内生效。当然具体时长由浏览器决定,可以查看这篇文章《Why Web Browser DNS Caching Can Be A Bad Thing

清理ChromeDNS缓存的两种办法

手动清理

键入chrome://net-internals/#dns 。

触发 Tools-> Clear cache 和 Flush Sockets

935E2A9A-CCE3-48b8-9977-E8DC9C6AB154

等同于 Console控制台中键入

  • chrome.send('clearHostResolverCache')
  • chrome.send('clearBrowserCache')
  • chrome.send('flushSocketPools')

借助远程调试清理

配置启动参数:

  • --enable-benchmarking : 启用基准测试扩展
  • --enable-net-benchmarking : 启用网络基准测试扩展
  • --remote-debugging-port=9222 : 开启远程调试
 google-chrome --enable-benchmarking --enable-net-benchmarking --remote-debugging-port=9222

配置window

    1、快捷方式

å¿«æ·æ¹å¼

    2、注册表 (全局配置)

路径:HKEY_LOCAL_MACHINE\SOFTWARE\Classes\ChromeHTML\shell\open\command

修改为: "/YOUR_CHROMEPATH/chrome.exe" --enable-benchmarking --enable-net-benchmarking --remote-debugging-port=9222 -- "%1"

注å表

配置macOS

1、切换Google安装目录

cd "/Applications/Google Chrome.app/Contents/MacOS/"

2、重命名的启动脚本

sudo mv "Google Chrome" Google.real

3、编辑启动脚本

vim "Google Chrome"

4、键入启动参数

   #!/bin/bash
   cd "/Applications/Google Chrome.app/Contents/MacOS"
   "/Applications/Google Chrome.app/Contents/MacOS/Google.real" --enable-benchmarking --enable-net-benchmarking --remote-debugging-port=9222

é®å¥å¯å¨åæ°

5、Shift+Q 退回正常模式,X 保存并退出

6、添加执行权限

sudo chmod u+x "Google Chrome"

 å®æ´ææ

配置linux

1、打开 Chrome 启动脚本

vim /usr/bin/google-chrome

2、命令行 exec -a "$0" "$HERE/chrome" "$@" 之后, 追加启动参数

exec -a "$0" "$HERE/chrome" "$@" --enable-benchmarking --enable-net-benchmarking --remote-debugging-port=9222

 3、Shift+Q 退回正常模式,X 保存并退出

注意: Root账户中使用Chrome,需追加 --no-sandbox --user-data-dir 启动沙盒模式。 虚拟机环境下,需关闭3D加速。

å®æ´ææ

检查配置是否成功

Chrome 浏览器 键入 chrome://version/

éç½®æå

Console控制台键入

chrome.benchmarking.clearHostResolverCache();
chrome.benchmarking.clearCache();
chrome.benchmarking.closeConnections();

集成工具:

  • SwitchHosts :集成Hosts切换管理和清理Chrome DNS Cache功能。当修改Hosts信息时,立即刷新Chrome DNS Cache,实现Hosts立即生效。
  • chrome-dns-clear :支持集成到Node项目。

猜你喜欢

转载自blog.csdn.net/qq_27559331/article/details/89886059