Code Monkey home page Code Monkey logo

github-hosts's Introduction

GitHub 访问速度慢,图片无法加载?一劳永逸的解决方法

GitHub top language

不知道从什么时候我访问github就无法展示图片了,而且有时候(尤其晚上)打开网页速度慢,这个项目就是为了一劳永逸的解决问题.

应用后的效果就是:网页打开快了,Github 图片可以正常加载。

本项目会实时更新最新的 hosts , 你不用在每次去网上找那些可能已经过期的,所以给个 star 不迷路。

使用方法

hosts

内容定时更新,最近更新时间:2022年1月26日 上午7:54:53

# GitHub Host Start

185.199.108.154               github.githubassets.com
140.82.112.22                 central.github.com
185.199.108.133               desktop.githubusercontent.com
185.199.108.153               assets-cdn.github.com
185.199.108.133               camo.githubusercontent.com
185.199.108.133               github.map.fastly.net
199.232.69.194                github.global.ssl.fastly.net
140.82.112.3                  gist.github.com
185.199.108.153               github.io
140.82.113.3                  github.com
140.82.113.6                  api.github.com
185.199.108.133               raw.githubusercontent.com
185.199.108.133               user-images.githubusercontent.com
185.199.108.133               favicons.githubusercontent.com
185.199.108.133               avatars5.githubusercontent.com
185.199.108.133               avatars4.githubusercontent.com
185.199.108.133               avatars3.githubusercontent.com
185.199.108.133               avatars2.githubusercontent.com
185.199.108.133               avatars1.githubusercontent.com
185.199.108.133               avatars0.githubusercontent.com
185.199.108.133               avatars.githubusercontent.com
140.82.112.9                  codeload.github.com
52.217.95.209                 github-cloud.s3.amazonaws.com
52.217.137.57                 github-com.s3.amazonaws.com
52.216.138.163                github-production-release-asset-2e65be.s3.amazonaws.com
52.217.36.228                 github-production-user-asset-6210df.s3.amazonaws.com
52.217.169.81                 github-production-repository-file-5c1aeb.s3.amazonaws.com
185.199.108.153               githubstatus.com
64.71.144.202                 github.community
185.199.108.133               media.githubusercontent.com

# Please Star: https://github.com/isevenluo/github-hosts
# Please Star: https://gitee.com/isevenluo/github-hosts
# Update at: 2022年1月26日 上午7:54:53

# GitHub Host End

手动配置

macOS

hosts 文件位置: /etc/hosts

macOS 修改需要管理员权限,所以需要按照如下方式配置:

  1. 首先,打开(访达)Finder。
  2. 使用组合键 Shift+Command+G 打开"前往文件夹",输入框中输入 /etc/hosts
  3. 然后就会跳转到 hosts 文件位置。

注意:如果你使用VS Code,可以直接用VS Code修改和保存,不需要复制文件。

复制hosts文件到桌面上,鼠标右键右击它,选择「打开方式」—「文本编辑」,打开这个hosts文件,把上面的hosts内容复制进来。

然后用你修改好的hosts文件替换掉:/etc/hosts 文件。

注意:如果弹出密码输入框,你需要输入你当前登录账号对应的密码。

最后刷新缓存:

sudo killall -HUP mDNSResponder

Windows

hosts文件位置:C:/windows/system32/drivers/etc/hosts

将上面提供的 hosts 内容追加到hosts文件,然后刷新DNS缓存:

ipconfig /flushdns

如果你不愿意安装其他软件,那么使用这种手动操作的方式即可,缺点:可能过一段时间 github 访问又慢了,图片无法加载了,你就需要 star 我这个项目,然后来获取最新的 hosts 内容去替换你本地的。

不过我更推荐使用下面 SwitchHosts 这种自动更新一劳永逸的方法。

使用 SwitchHosts,远程自动更新

如果对 SwitchHosts 感兴趣的同学,可以访问其官网查看:https://swh.app/zh/

放一张软件的截图,还是很简约好用的。

这款软件支持 WindwosmacOS 系统,使用方式时一样的。

软件下载地址:https://github.com/oldj/SwitchHosts/releases

设置定时同步云端最新hosts

安装好 SwitchHosts 后,打开软件新增一条远程规则:

这样你就可以定时获取最新的 hosts 了,再也不用担心 github 无法访问,图片加载不了了。

PS:记着不要忘记点击侧边栏的开关哦~~

image-20210428223111467

如果对你有用,不妨 star 一下可好。

github-hosts's People

Contributors

isevenluo avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.