Small knowledge, big challenge! This article is participating in the creation activity of “Essential Tips for Programmers”
I often look for some interesting learning projects on Github, but the github page often opens slowly or even cannot be opened, which often leads to the disruption of the plan and the instant I don’t want to learn. Today we’ll summarize the solutions to github’s slow access.
Slow or inaccessible GitHub access is usually caused by the following problems:
- Local network access is slow and scientific Internet access is fast
- Local network inaccessible (inaccessible due to response time)
- Github’s accelerated distribution CDN domain assets-cdn.github.com is unavailable due to DNS contamination
1. Modify the local hosts mapping
Domain name resolution points directly to GitHub’s IP address, bypassing DNS resolution
1.1 Viewing the Latest GitHub IP Address
Query the latest IP address of GitHub in IP address query website
- github.com
- github.global.ssl.fastly.net
- assets-cdn.github.com
- codeload.github.com
You can also use another method to query the IP address of the specified web site:
① Directly request the website as a parameter, omit the step of clicking query:
- Websites.ipaddress.com/github.glob…
- websites.ipaddress.com/github.com
- Websites.ipaddress.com/assets-cdn….
- Websites.ipaddress.com/codeload.gi…
② Join the IP query website in the later query
- github.global.ssl.fastly.net.ipaddress.com/
- github.com.ipaddress.com/
- assets-cdn.github.com.ipaddress.com/
- codeload.github.com.ipaddress.com/
1.2 Mapping IP addresses to the local hosts file
After finding the corresponding IP address, map the IP address to the website address, and write the mapping to the local hosts file.
In Windows system of c: / Windows/System32 / drivers/hosts file, found under the etc editor opens, the four sites corresponding to write into the IP address and a web address, as the DNS mapping.
You may not have permission to edit the hosts file. You can perform the following operations to modify the file:
- To change the current file permission, right-click hosts file, select Properties, Security, edit, Users, and add write permission to Users
- Copy the current file to another disk, modify the file and copy it back to overwrite the original file
#github DNS mapping format: [domainName] 199.232.69.194 140.82.114.4 185.199.108.153 assets-cdn.Github.com GitHub.com github.global.ssl.Fastly.net 140.82.114.9 codeload.Github.comCopy the code
1.3 Refresh the DNS cache to access the new mapping
After the hosts file is updated successfully, you need to refresh the DNS of the Windows operating system for the update to take effect.
Run the win+R command, open the CMD command line interface, and enter ipconfig/flushdns to flush the DNS cache.
After the refresh, the speed of the github website will be significantly improved when you open it again. It should be noted that the IP address of the above Github website often changes. If the access becomes slow again, you can update the mapping information.
2. One-click update
Manually updating the local hosts file is cumbersome. Instead of manually updating the local hosts file, you can write programs to update the contents of the hosts file with one click when necessary.
Recommend a Github open source project: Update hosts, the author will provide the latest IP address mapping information every day, we can directly copy and use or use the program for one-click update operation.
As a coder, we can also implement a script ourselves.
3. The Chrome plug-ins
Chrome plug-ins such as Github acceleration can be implemented when accessing and downloading projects using image acceleration to improve access speed.
If you cannot access the Chrome plug-in, you are advised to use the chrome plug-in download website: Extfans. After downloading the plug-in, you can use the developer mode to install the plug-in.
4. Mirror sites
Github is slow to access, we can also use a mirror site instead of Github
- github.com.cnpmjs.org
- hub.fastgit.org
As mirror websites, the above two websites basically contain the existing project information on Github, and you can view and download relevant projects with good speed, which can be used as standby websites.