去年年末开始GitHub
里面的用户头像没法显示,页面也加载缓慢,这下快乐的日子可能一去不复返了,咱们须要把相关域名加加速了。git
GitHub
里面图片都在githubusercontent.com
域名上,咱们只须要在hosts
里面加上相关地址便可。若是你有代理,把域名加入到许可名单也能够的。github
这里咱们介绍hosts
方式是如何使用的,把如下内容添加到hosts
文件中。shell
# 2020年12月30日更新 # GitHub Start 52.74.223.119 github.com 52.74.223.119 gist.github.com 54.169.195.247 api.github.com 185.199.111.153 assets-cdn.github.com 199.232.96.133 raw.githubusercontent.com 199.232.96.133 gist.githubusercontent.com 199.232.96.133 cloud.githubusercontent.com 199.232.96.133 camo.githubusercontent.com 199.232.96.133 avatars0.githubusercontent.com 199.232.96.133 avatars1.githubusercontent.com 199.232.96.133 avatars2.githubusercontent.com 199.232.96.133 avatars3.githubusercontent.com 199.232.96.133 avatars4.githubusercontent.com 199.232.96.133 avatars5.githubusercontent.com 199.232.96.133 avatars6.githubusercontent.com 199.232.96.133 avatars7.githubusercontent.com 199.232.96.133 avatars8.githubusercontent.com 199.232.96.133 user-images.githubusercontent.com 185.199.109.154 github.githubassets.com # GitHub End
注意 : 这里域名对应的ip是经过dns查询工具查询获得的,你应当选择的是延时相对较小且比较稳定的ip。
若是发现不起做用,或者速度不理想,参考查找域名IP。windows
这里推荐使用 SwitchHosts!
配置hosts
,操做很简单,支持跨平台。api
复制前面的hosts内容到软件里配置便可,相关介绍参考下面文章。缓存
SwitchHosts! 还能这样管理hosts,后悔没早点用工具
hosts文件位置:C:/windows/system32/drivers/etc/hosts
。测试
将前文内容追加到hosts
,而后刷新DNS
缓存:代理
ipconfig /flushdns
hosts文件位置:/etc/hosts
。code
Mac
系统下修改须要按照以下方式:
Shift+Command+G
打开"前往文件夹",在输入框输入/etc/hosts
。hosts
文件位置。复制hosts
文件到桌面上,鼠标右键点击/右击它,选择「打开方式」—「文本编辑」,打开这个hosts
文件,而后将你要修改的内容直接在里面修改就行了。
而后把你修改好的hosts
文件在复制回hosts
文件的所在(文件夹下)路径:/etc/hosts
之下替换原始的hosts
文件就行了。
注意:若是弹出密码输入框,你须要输入你当前电脑登陆帐号的密码。
最后刷新下缓存:
sudo killall -HUP mDNSResponder
注:2020年12月30日我实际使用IPAddress
才能够生效,前面两个查询站点获取的IP
均没法使用,各位能够都尝试下直到生效。
前面hosts
里面域名里分为两类:
*.githubusercontent.com
可使用同一个IP
,不须要每一个单独查询。*.github.com
未经测试,目前看是须要单独查询对应的IP
。