GitHub CDN
http://ping.chinaz.com/cdn.jsdelivr.net
图片
github repo: https://github.com/weilining/img/blob/main/img/72.png
github raw: https://raw.githubusercontent.com/weilining/img/main/img/72.png
jsdelivr(github cdn): https://cdn.jsdelivr.net/gh/weilining/img/img/72.png
purge
1 | curl https://purge.jsdelivr.net/gh/weilining/img/img/72.png |
没有error即可,出现error就运行代码多次
js、css
同图片的使用
使用 jsdelivr 加速 Github 仓库资源背景等图
当我们使用 Github 仓库资源时,会因为一些奇怪的原因而掉链子,但我们可以通过 jsdelivr 做 CDN 加速
jsdelivr 是一个免费的开源 CDN
使用方式:
https://cdn.jsdelivr.net/gh/ Github 用户名/仓库名/资源路径
默认会访问 master 分支下的资源,可以通过 仓库名拼接 @ + release / commit / branch 来访问特定版本下的资源
例子:
https://raw.githubusercontent.com/weilining/blog.io/master/images/background-dark.jpg
https://cdn.jsdelivr.net/gh/weilining/blog.io/images/background-dark.jpg
头像
GitHub地址:https://github.com/weilining/blog.io/blob/master/images/logo.svg
jsdelivr地址:https://cdn.jsdelivr.net/gh/weilining/blog.io/images/logo.svg
你输入https://cdn.jsdelivr.net/gh/weilining
提示:Invalid URL. The URL structure is /gh/user/repo@version/file.js
也就是说jsdelivr其实本身就是加速js的
GitHub CDN
根据 jsdelivr 说明,要使用 GitHub CDN,需要仓库设为公开,且打上 git tag 版本号。小提示,jsdelivr 支持不带版本号的 url,但发布到线上的页面一定要带版本号,不然很可能因为缓存问题使用的不是最新的资源。






