基于 Cloudflare Workers 的高性能 GitHub 文件加速代理服务。
A high-performance GitHub file acceleration proxy service based on Cloudflare Workers.
- 🚀 零配置部署 - 无需 KV 存储,一键即用
- ⚡ 智能缓存 - 多层缓存策略,根据路径类型自动调整 TTL
- 🌐 全域名支持 - 支持
github.com、api.github.com、raw.githubusercontent.com、gist.github.com等 - 📦 完整功能 - 断点续传、CORS 支持、ETag 验证
- 🔧 可靠性优化 - 重试机制、超时控制、连接优化
- 🎨 精美首页 - 中英双语界面,支持三种 URL 格式说明
- 🌓 智能主题 - 自动跟随系统浅色/深色主题,支持手动切换
- 🌍 自动语言检测 - 根据浏览器语言自动选择中文/英文界面
- 🔄 实时主题同步 - 系统主题变化时自动切换,无需刷新
- 📋 域名自动替换 - 示例 URL 自动显示当前访问域名,即用即改
- 🎯 状态记忆 - 使用 sessionStorage 保存用户偏好,刷新后恢复系统设置
系统根据文件路径自动选择最优缓存策略:
| 路径类型 | 示例 | Edge 缓存 | 浏览器缓存 | 版本控制 |
|---|---|---|---|---|
| 动态内容 | /latest/, /main/, /nightly/ |
1 小时 | 5 分钟 | ETag |
| 固定版本 | /v1.0/, /tags/, /releases/download/v1.0/ |
30 天 | 1 天 | 日期 |
| 普通路径 | 其他所有路径 | 1 天 | 1 小时 | ETag |
点击下方按钮,自动部署到 Cloudflare Workers:
步骤:
- 点击上方按钮
- 登录 Cloudflare 账号
- 授权 GitHub 仓库访问
- 点击 "Deploy" 按钮
- 等待部署完成(约 1-2 分钟)
- 获取 Worker URL(格式:
https://your-worker.workers.dev)
前置要求:
- Cloudflare 账号(免费注册)
- (建议)托管到 Cloudflare 的域名 - 用于绑定自定义域名,避免
*.workers.dev域名被封锁的风险
部署步骤:
-
登录 Cloudflare Dashboard
访问:https://dash.cloudflare.com/ -
创建 Worker
- 点击左侧菜单
Workers & Pages - 点击
Create Application - 选择
Create Worker - 输入 Worker 名称(例如:
github-proxy) - 点击
Deploy
- 点击左侧菜单
-
部署代码
- 点击
Edit Code按钮 - 删除默认代码
- 复制
worker.js的完整内容 - 粘贴到编辑器
- 点击右上角
Save and Deploy
- 点击
-
绑定自定义域名(可选)
- 在 Worker 详情页,点击
Settings→Triggers - 点击
Add Custom Domain - 输入域名(例如:
gh.example.com) - 等待 DNS 配置生效(通常 1-5 分钟)
- 在 Worker 详情页,点击
-
完成部署 ✅
- 默认 URL:
https://your-worker.workers.dev - 自定义域名:
https://gh.example.com(如已配置)
- 默认 URL:
配置 GitHub Actions 实现代码 push 后自动部署,保持 Worker 与仓库同步。
配置步骤:查看 自动部署配置指南
将 GitHub URL 的域名替换为您的 Worker 域名:
# 原始 URL
https://github.com/torvalds/linux/archive/refs/tags/v6.6.tar.gz
# 加速 URL(使用 Workers 域名)
https://your-worker.workers.dev/torvalds/linux/archive/refs/tags/v6.6.tar.gz
# 加速 URL(使用自定义域名)
https://gh.example.com/torvalds/linux/archive/refs/tags/v6.6.tar.gz1. 简洁格式(推荐)
https://your-worker.workers.dev/user/repo/releases/download/v1.0/file.zip
https://your-worker.workers.dev/user/repo/archive/refs/tags/v1.0.tar.gz
2. 完整格式(显式指定域名)
https://your-worker.workers.dev/github.com/user/repo/releases/download/v1.0/file.zip
https://your-worker.workers.dev/raw.githubusercontent.com/user/repo/main/script.sh
https://your-worker.workers.dev/gist.githubusercontent.com/user/gist-id/raw/file.txt
下载 Release 文件
# 下载 Clash Meta 核心
wget https://your-worker.workers.dev/MetaCubeX/mihomo/releases/download/v1.18.0/mihomo-linux-amd64
# 下载 Node.js 源码
curl -O https://your-worker.workers.dev/nodejs/node/archive/refs/tags/v20.10.0.tar.gz获取 Raw 文件
# 获取脚本文件
curl https://your-worker.workers.dev/raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash
# 获取配置文件
wget https://your-worker.workers.dev/raw.githubusercontent.com/torvalds/linux/master/.gitignore在脚本中使用
#!/bin/bash
# 设置镜像地址
GITHUB_PROXY="https://your-worker.workers.dev"
# 下载文件
download_file() {
local repo=$1
local tag=$2
local filename=$3
wget "${GITHUB_PROXY}/${repo}/releases/download/${tag}/${filename}"
}
# 使用示例
download_file "cli/cli" "v2.40.0" "gh_2.40.0_linux_amd64.tar.gz"Git Clone 加速
# 方法1: 使用 git config
git config --global url."https://your-worker.workers.dev/".insteadOf "https://github.com/"
git clone https://github.com/torvalds/linux.git
# 方法2: 直接替换 URL
git clone https://your-worker.workers.dev/torvalds/linux.git在 worker.js 中可自定义以下参数:
| 参数 | 默认值 | 说明 |
|---|---|---|
EDGE_CACHE_SECONDS |
2592000 (30天) |
边缘缓存 TTL |
SWR_SECONDS |
86400 (1天) |
过期后仍可用时间 |
BROWSER_CACHE_SECONDS |
3600 (1小时) |
浏览器缓存 TTL |
| 参数 | 默认值 | 说明 |
|---|---|---|
ENABLE_COMPRESSION |
true |
启用 Brotli/Gzip 压缩 |
ENABLE_EARLY_HINTS |
true |
启用 Early Hints (HTTP 103) |
MAX_RETRIES |
2 |
请求失败最大重试次数 |
RETRY_DELAY_MS |
500 |
重试间隔(毫秒) |
REQUEST_TIMEOUT_MS |
30000 |
请求超时时间(毫秒) |
- ✅ HTTP/3 & HTTP/2 - 多路复用,减少连接开销
- ✅ Early Hints - 提前预连接,降低首字节时间
- ✅ Keep-Alive - 连接复用,减少 TCP 握手
- ✅ Smart DNS - 使用 Cloudflare DNS (1.1.1.1)
- ✅ 多层缓存 - 浏览器 → Worker → Edge 三层缓存
- ✅ 智能失效 - 基于 ETag 和日期的自动版本管理
- ✅ Vary 支持 - 基于编码类型的缓存变体
- ✅ SWR 机制 - 后台异步更新,减少阻塞
- ✅ 智能重试 - 指数退避算法,避免雪崩
- ✅ 超时控制 - 30 秒超时,避免长时间等待
- ✅ 错误降级 - 支持配置备用镜像源
- ✅ 自动压缩 - HTML/CSS/JS Minify
- ✅ 图片优化 - Polish 有损压缩
- ✅ 智能加载 - Mirage 自适应图片
Worker 会添加以下调试头:
| 响应头 | 说明 | 示例值 |
|---|---|---|
X-Cache-Status |
缓存命中状态 | HIT / MISS |
X-Cache-Strategy |
缓存策略类型 | dynamic / versioned / default |
X-Mirror-Version |
缓存版本号 | 20231223 / abc123... (ETag) |
X-GitHub-Target |
实际请求的 GitHub URL | https://github.com/... |
X-Response-Time |
响应时间 | 1234ms |
调试示例:
curl -I https://your-worker.workers.dev/cli/cli/releases/download/v2.40.0/gh_2.40.0_linux_amd64.tar.gz
HTTP/2 200
x-cache-status: HIT
x-cache-strategy: versioned
x-mirror-version: 20231223
x-response-time: 45ms-
限制说明
- 免费版每日 100,000 次请求限制
- 单文件大小限制 100MB(Cloudflare 限制)
- CPU 执行时间 50ms(免费版)/ 无限制(付费版)
-
缓存行为
- 浏览器缓存:根据策略自动调整(5分钟 - 1天)
- 边缘缓存:根据策略自动调整(1小时 - 30天)
- 版本号:每天 UTC 00:00 自动更新
-
使用建议
- 建议先测试小文件,确认正常后再用于大文件
- 如需频繁访问,建议绑定自定义域名
- 大量请求建议升级到 Workers Paid 计划
-
清除缓存
- Dashboard:
Caching→Configuration→Purge Cache - API:使用 Cloudflare API 按 URL 清除
- 自动:等待缓存过期或版本号更新
- Dashboard:
问题:404 Not Found
检查路径格式是否正确
确认 GitHub 上该文件确实存在
查看 X-GitHub-Target 头确认目标 URL
问题:缓存未命中(X-Cache-Status: MISS)
首次请求必定 MISS,再次请求应为 HIT
检查是否为动态路径(/latest/ 等)
查看 X-Cache-Strategy 确认策略类型
问题:下载速度慢
检查是否使用了 Cloudflare CDN 节点
确认本地网络到 Cloudflare 的连接质量
查看 X-Response-Time 分析延迟来源
查看 Releases 获取版本历史。
欢迎提交 Issue 和 Pull Request!
贡献指南:
- Fork 本项目
- 创建功能分支 (
git checkout -b feature/AmazingFeature) - 提交更改 (
git commit -m 'Add some AmazingFeature') - 推送到分支 (
git push origin feature/AmazingFeature) - 开启 Pull Request
本项目采用 GNU General Public License v3.0 许可证。
- Cloudflare Workers - 强大的边缘计算平台
- GitHub - 全球最大的代码托管平台
- 🚀 Zero Configuration - No KV storage, one-click deployment
- ⚡ Intelligent Caching - Multi-layer caching strategy with automatic TTL adjustment
- 🌐 Full Domain Support - Supports
github.com,api.github.com,raw.githubusercontent.com,gist.github.com, etc. - 📦 Complete Features - Resumable downloads, CORS support, ETag validation
- 🔧 Reliability - Retry mechanism, timeout control, connection optimization
- 🎨 Beautiful Homepage - Bilingual interface with three URL format examples
- 🌓 Smart Theme - Auto-follows system light/dark theme with manual toggle
- 🌍 Auto Language Detection - Automatically selects Chinese/English based on browser language
- 🔄 Real-time Theme Sync - Auto-switches when system theme changes, no refresh needed
- 📋 Dynamic Domain Replacement - Example URLs automatically show current accessing domain
- 🎯 Preference Memory - Uses sessionStorage to save user preferences, resets to system on refresh
The system automatically selects the optimal caching strategy based on file paths:
| Path Type | Example | Edge Cache | Browser Cache | Version Control |
|---|---|---|---|---|
| Dynamic Content | /latest/, /main/, /nightly/ |
1 hour | 5 minutes | ETag |
| Versioned Paths | /v1.0/, /tags/, /releases/download/v1.0/ |
30 days | 1 day | Date |
| Regular Paths | All other paths | 1 day | 1 hour | ETag |
Click the button below to automatically deploy to Cloudflare Workers:
Steps:
- Click the button above
- Log in to your Cloudflare account
- Authorize GitHub repository access
- Click the "Deploy" button
- Wait for deployment to complete (about 1-2 minutes)
- Get your Worker URL (format:
https://your-worker.workers.dev)
Prerequisites:
- Cloudflare account (Free Sign Up)
- (Recommended) A domain hosted on Cloudflare - For binding custom domain to avoid
*.workers.devblocking risks
Deployment Steps:
-
Log in to Cloudflare Dashboard
Visit: https://dash.cloudflare.com/ -
Create Worker
- Click
Workers & Pagesin the left menu - Click
Create Application - Select
Create Worker - Enter Worker name (e.g.,
github-proxy) - Click
Deploy
- Click
-
Deploy Code
- Click the
Edit Codebutton - Delete the default code
- Copy the complete content of
worker.js - Paste into the editor
- Click
Save and Deployin the top right
- Click the
-
Bind Custom Domain (Optional)
- On the Worker details page, click
Settings→Triggers - Click
Add Custom Domain - Enter domain (e.g.,
gh.example.com) - Wait for DNS configuration to take effect (usually 1-5 minutes)
- On the Worker details page, click
-
Deployment Complete ✅
- Default URL:
https://your-worker.workers.dev - Custom domain:
https://gh.example.com(if configured)
- Default URL:
Configure GitHub Actions to automatically deploy when code is pushed, keeping your Worker synchronized with the repository.
Configuration Steps: See Auto-Deployment Configuration Guide
Replace the domain in GitHub URLs with your Worker domain:
# Original URL
https://github.com/torvalds/linux/archive/refs/tags/v6.6.tar.gz
# Accelerated URL (using Workers domain)
https://your-worker.workers.dev/torvalds/linux/archive/refs/tags/v6.6.tar.gz
# Accelerated URL (using custom domain)
https://gh.example.com/torvalds/linux/archive/refs/tags/v6.6.tar.gz1. Simplified Format (Recommended)
https://your-worker.workers.dev/user/repo/releases/download/v1.0/file.zip
https://your-worker.workers.dev/user/repo/archive/refs/tags/v1.0.tar.gz
2. Full Format (Explicit domain)
https://your-worker.workers.dev/github.com/user/repo/releases/download/v1.0/file.zip
https://your-worker.workers.dev/raw.githubusercontent.com/user/repo/main/script.sh
https://your-worker.workers.dev/gist.githubusercontent.com/user/gist-id/raw/file.txt
Download Release Files
# Download Clash Meta core
wget https://your-worker.workers.dev/MetaCubeX/mihomo/releases/download/v1.18.0/mihomo-linux-amd64
# Download Node.js source code
curl -O https://your-worker.workers.dev/nodejs/node/archive/refs/tags/v20.10.0.tar.gzGet Raw Files
# Get script file
curl https://your-worker.workers.dev/raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash
# Get configuration file
wget https://your-worker.workers.dev/raw.githubusercontent.com/torvalds/linux/master/.gitignoreUse in Scripts
#!/bin/bash
# Set proxy address
GITHUB_PROXY="https://your-worker.workers.dev"
# Download file
download_file() {
local repo=$1
local tag=$2
local filename=$3
wget "${GITHUB_PROXY}/${repo}/releases/download/${tag}/${filename}"
}
# Usage example
download_file "cli/cli" "v2.40.0" "gh_2.40.0_linux_amd64.tar.gz"Git Clone Acceleration
# Method 1: Use git config
git config --global url."https://your-worker.workers.dev/".insteadOf "https://github.com/"
git clone https://github.com/torvalds/linux.git
# Method 2: Direct URL replacement
git clone https://your-worker.workers.dev/torvalds/linux.gitCustomize the following parameters in worker.js:
| Parameter | Default | Description |
|---|---|---|
EDGE_CACHE_SECONDS |
2592000 (30 days) |
Edge cache TTL |
SWR_SECONDS |
86400 (1 day) |
Stale-while-revalidate duration |
BROWSER_CACHE_SECONDS |
3600 (1 hour) |
Browser cache TTL |
| Parameter | Default | Description |
|---|---|---|
ENABLE_COMPRESSION |
true |
Enable Brotli/Gzip compression |
ENABLE_EARLY_HINTS |
true |
Enable Early Hints (HTTP 103) |
MAX_RETRIES |
2 |
Maximum retry attempts |
RETRY_DELAY_MS |
500 |
Retry interval (milliseconds) |
REQUEST_TIMEOUT_MS |
30000 |
Request timeout (milliseconds) |
- ✅ HTTP/3 & HTTP/2 - Multiplexing, reduced connection overhead
- ✅ Early Hints - Pre-connect, lower TTFB
- ✅ Keep-Alive - Connection reuse, reduced TCP handshake
- ✅ Smart DNS - Using Cloudflare DNS (1.1.1.1)
- ✅ Multi-Layer Cache - Browser → Worker → Edge three-tier caching
- ✅ Smart Invalidation - Automatic version management based on ETag and date
- ✅ Vary Support - Cache variants based on encoding type
- ✅ SWR Mechanism - Background async update, reduced blocking
- ✅ Smart Retry - Exponential backoff algorithm
- ✅ Timeout Control - 30-second timeout
- ✅ Error Fallback - Support for fallback mirror sources
- ✅ Auto Minify - HTML/CSS/JS minification
- ✅ Image Optimization - Polish lossy compression
- ✅ Smart Loading - Mirage adaptive images
The Worker adds the following debug headers:
| Header | Description | Example Value |
|---|---|---|
X-Cache-Status |
Cache hit status | HIT / MISS |
X-Cache-Strategy |
Cache strategy type | dynamic / versioned / default |
X-Mirror-Version |
Cache version | 20231223 / abc123... (ETag) |
X-GitHub-Target |
Actual GitHub URL requested | https://github.com/... |
X-Response-Time |
Response time | 1234ms |
Debug Example:
curl -I https://your-worker.workers.dev/cli/cli/releases/download/v2.40.0/gh_2.40.0_linux_amd64.tar.gz
HTTP/2 200
x-cache-status: HIT
x-cache-strategy: versioned
x-mirror-version: 20231223
x-response-time: 45ms-
Limitations
- Free tier: 100,000 requests per day
- Single file size limit: 100MB (Cloudflare limitation)
- CPU execution time: 50ms (free) / unlimited (paid)
-
Cache Behavior
- Browser cache: Auto-adjusted based on strategy (5min - 1day)
- Edge cache: Auto-adjusted based on strategy (1hour - 30days)
- Version number: Auto-updated daily at UTC 00:00
-
Recommendations
- Test with small files first before using for large files
- Bind custom domain for frequent access
- Upgrade to Workers Paid plan for high traffic
-
Cache Purging
- Dashboard:
Caching→Configuration→Purge Cache - API: Use Cloudflare API to purge by URL
- Auto: Wait for cache expiration or version update
- Dashboard:
Issue: 404 Not Found
Check if path format is correct
Verify the file exists on GitHub
Check X-GitHub-Target header for target URL
Issue: Cache Miss (X-Cache-Status: MISS)
First request must be MISS, subsequent should be HIT
Check if it's a dynamic path (/latest/, etc.)
Review X-Cache-Strategy to confirm strategy type
Issue: Slow Download Speed
Check if using Cloudflare CDN nodes
Verify local network connection quality to Cloudflare
Review X-Response-Time to analyze latency source
See Releases for version history.
Issues and Pull Requests are welcome!
Contribution Guidelines:
- Fork the project
- Create feature branch (
git checkout -b feature/AmazingFeature) - Commit changes (
git commit -m 'Add some AmazingFeature') - Push to branch (
git push origin feature/AmazingFeature) - Open Pull Request
This project is licensed under the GNU General Public License v3.0.
- Cloudflare Workers - Powerful edge computing platform
- GitHub - The world's largest code hosting platform
Made with ❤️ by Aethersailor