前言
最近网站大部分图片访问变慢, 原因出在jsdelivr
加速失效, 为此我更换了CDN域名, 顺带总结一下github
加速小技巧
GitHub访问加速
1. 使用镜像访问
这相当于是克隆版的 GitHub , 网站的内容和 GitHub 是完整同步, 可以在这个网站里面进行下载克隆等操作, 镜像地址如下:
使用示范:
1 2 3 4 5
| https://github.com/typecho/typecho
可以改成
https://hub.fastgit.xyz/typecho/typecho
|
2.修改Host文件加速
首先需要获取对应域名实际ip地址, 可以通过以下网站查询:

需要查询的地址有:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| # 基本地址 'github.com', 'gist.github.com', 'assets-cdn.github.com', 'raw.githubusercontent.com', 'gist.githubusercontent.com', 'cloud.githubusercontent.com', 'camo.githubusercontent.com', 'avatars0.githubusercontent.com', 'avatars1.githubusercontent.com', 'avatars2.githubusercontent.com', 'avatars3.githubusercontent.com', 'avatars4.githubusercontent.com', 'avatars5.githubusercontent.com', 'avatars6.githubusercontent.com', 'avatars7.githubusercontent.com', 'avatars8.githubusercontent.com', 'avatars.githubusercontent.com', 'github.githubassets.com', 'user-images.githubusercontent.com', 'codeload.github.com', 'favicons.githubusercontent.com', 'api.github.com'
|
一个一个查询太过麻烦, 可以使用python脚本快速批量获取, 代码如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
| #!/usr/bin/env python # coding:utf-8 import socket
def output_hosts(): domains = ['github.com', 'gist.github.com', 'assets-cdn.github.com', 'raw.githubusercontent.com', 'gist.githubusercontent.com', 'cloud.githubusercontent.com', 'camo.githubusercontent.com', 'avatars0.githubusercontent.com', 'avatars1.githubusercontent.com', 'avatars2.githubusercontent.com', 'avatars3.githubusercontent.com', 'avatars4.githubusercontent.com', 'avatars5.githubusercontent.com', 'avatars6.githubusercontent.com', 'avatars7.githubusercontent.com', 'avatars8.githubusercontent.com', 'avatars.githubusercontent.com', 'github.githubassets.com', 'user-images.githubusercontent.com', 'codeload.github.com', 'favicons.githubusercontent.com', 'api.github.com' ] with open('hosts.txt', 'w') as f: f.write('```\n') f.write('# GitHub Start \n') for domain in domains: print('Querying ip for domain %s'%domain) ip = socket.gethostbyname(domain) print(ip) f.write('%s %s\n'%(ip, domain)) f.write('# GitHub End \n') f.write('```\n') if __name__ == '__main__': output_hosts()
|
执行脚本后, 得到如下结果:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| # GitHub Start 140.82.121.3 github.com 140.82.121.3 gist.github.com 185.199.110.153 assets-cdn.github.com 185.199.108.133 raw.githubusercontent.com 185.199.111.133 gist.githubusercontent.com 185.199.110.133 cloud.githubusercontent.com 185.199.111.133 camo.githubusercontent.com 185.199.111.133 avatars0.githubusercontent.com 185.199.110.133 avatars1.githubusercontent.com 185.199.111.133 avatars2.githubusercontent.com 185.199.109.133 avatars3.githubusercontent.com 185.199.108.133 avatars4.githubusercontent.com 185.199.111.133 avatars5.githubusercontent.com 185.199.109.133 avatars6.githubusercontent.com 185.199.109.133 avatars7.githubusercontent.com 185.199.110.133 avatars8.githubusercontent.com 185.199.108.133 avatars.githubusercontent.com 185.199.111.154 github.githubassets.com 185.199.109.133 user-images.githubusercontent.com 140.82.112.9 codeload.github.com 185.199.110.133 favicons.githubusercontent.com 192.30.255.116 api.github.com # GitHub End
|
将以上内容拷贝到系统Host文件中即可, 不同操作系统host文件所在路径不一样:
Windows系统:修改C:\Windows\System32\drivers\etc\hosts
文件
1 2
| # 网络刷新 ipconfig /flushdns
|
Linux系统:修改C:\Windows\System32\drivers\etc\hosts
文件
1 2
| # 网络刷新 systemctl restart network
|
仓库Clone下载加速
1. 将仓库克隆到Gitee

插件" style="margin: 20px 0px 15px; padding: 10px 0px 0px; line-height: 1.5; font-family: Lato, "PingFang SC", "Microsoft YaHei", sans-serif; font-size: 14px; color: rgb(85, 85, 85); text-align: justify; white-space: normal; background-color: rgb(255, 255, 255);">2.使用Fast-GitHub浏览器插件
Fast-GitHub

3.第三方网站解析加速
Toolwa

gh-proxy

Ghproxy


Raw资源加速
1. 使用fastgit
将raw.githubusercontent.com
替换成raw.staticdn.net
或者raw.gitmirror.com
使用示例
实际上fastgit
功能很丰富, 几乎囊括了github
所有. 具体如下表:
反代列表
站源 | 地址 | 缓存 |
---|
github.com | hub.fastgit.xyz | 无 |
raw.githubusercontent.com | raw.staticdn.net | 无 |
github.githubassets.com | assets.fastgit.org | 无 |
customer-stories-feed.github.com | customer-stories-feed.fastgit.org | 480 分钟 |
Github Download | download.fastgit.org | 480 分钟 |
GitHub Archive | archive.fastgit.org | 无 |
fastgit官网
2.使用ghproxy
在https://raw.githubusercontent.com
地址前面添加https://ghproxy.com/
比如:
1
| https://ghproxy.com/https://raw.githubusercontent.com/stilleshan/ServerStatus/master/Dockerfile
|
推荐本站淘宝优惠价购买喜欢的宝贝:
本文链接:https://hqyman.cn/post/4571.html 非本站原创文章欢迎转载,原创文章需保留本站地址!
打赏

微信支付宝扫一扫,打赏作者吧~
休息一下~~