去年年末開始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
。