Skip to content

Serve downloads and updates from Cloudflare - #35

Merged
kewonit merged 5 commits into
mainfrom
cloudflare-download
Nov 21, 2026
Merged

kewonit merged 5 commits into
mainfrom
cloudflare-download

Conversation

@kewonit

@kewonit kewonit commented Nov 21, 2026 •

Copy link
Copy Markdown
Owner

GitHub sends Outbound's disk image slowly from here: today it managed about 128 KB/s, and at one point 20 KB/s, so a 5.9 MB download or update could take minutes. This serves releases from the site's own storage on Cloudflare instead.

What changes

  • /download now goes on to /download/Outbound-v1.9.dmg. That route streams the file from the private R2 bucket outbound-downloads and keeps it for a day in Cloudflare's cache where it was asked for. Resumed downloads get the rest, whether from the cache or from storage. Some part-of-file requests get the whole file from storage instead: a range storage can't serve, or a resume on a file that has changed since it began. A cache error falls through to storage. A file that isn't in the bucket, or a storage error, sends the download on to the file's GitHub release.
  • The 1.9 item in the appcast points at https://outbound.edbn.me/download/Outbound-v1.9.dmg. Its signature and length are unchanged, since it is the same file.
  • release.sh uploads the dmg and zip to the bucket before it makes the GitHub release, and writes new appcast items with the site's URL. Before building, it checks three things: that Wrangler can reach the bucket, that the version looks like 1.9 or 1.9.1, and that the appcast doesn't already offer that version. A release that stopped before the appcast step can simply be run again.
  • The site's download buttons link to /download even without JavaScript.
  • wrangler.jsonc binds the bucket as DOWNLOADS and names the edbn.me account, so Wrangler doesn't have to ask which account to use.
  • The privacy policy says downloads and updates come from this site on Cloudflare, with GitHub as the fallback.

Already done on Cloudflare

  • The bucket outbound-downloads is created. It is private, with no public URL, so nothing reaches it but the Worker.
  • The released 1.9 dmg and zip are in it, read back with the same SHA-256 as the GitHub assets.
  • Nothing is live until this merges.

Tested

  • Locally:
    • /download sends the browser on to the 1.9 dmg, and the bytes match GitHub's.
    • The second download is a cache hit.
    • Resumed downloads get a 206 with the right bytes, whether or not the file is cached, for byte ranges, open-ended ranges, last-N-byte ranges, ranges running past the end, and an If-Range that matches.
    • A stale If-Range, a range starting past the end, a two-piece range or a junk range each get the whole file with a 200.
    • All of the range checks were run again against the real bucket, through a wrangler dev --remote preview with a temporary test object that was deleted afterwards. HEAD there reports the 1.9 dmg's true size.
    • HEAD returns the size and type, and responses carry HSTS and nosniff.
    • With the bucket unavailable, the download goes to GitHub and the error is logged. With the cache forced to fail, the file still comes from storage.
    • A file missing from the bucket, or an unusual version name like Outbound-v2.0-beta.dmg, redirects to GitHub. Other names get a 404.
    • release.sh turns down 2, 2.0-beta and 1.9.0.1, and turns down 1.9, 1.8.1 and 1.8 because the appcast already offers them. It lets 2.0 and 1.9.1 through.
    • The rest of the site is unchanged.
  • Real update, run after each round of fixes: the shipped 1.8.1 updated itself to 1.9 from a test feed whose enclosure was served by this Worker. It staged in 2 s, installed on quit, and came out notarized.
  • On Cloudflare's servers (a wrangler dev --remote preview with the real bucket): 5.9 MB in 2.4 to 3.5 s. GitHub, in the same minute, sent 3.8 MB in 30 s and didn't finish.

After merging, check that https://outbound.edbn.me/download gives the dmg quickly and that the appcast shows the new 1.9 URL.

GitHub sent the disk image slowly, at times about 20 KB a second, so
downloads and updates could take minutes. The Worker now serves each
release from the outbound-downloads R2 bucket at /download/, keeps it in
the cache where it was asked for, and falls back to the GitHub release
for any file not in the bucket. release.sh uploads both files there
before it makes the GitHub release, and new appcast items point at the
site.
A storage or cache error now sends the download on to GitHub instead of
failing, and so does any Outbound-v name the bucket doesn't have, so a
hand-made version name still works. A download resumed part way gets
the rest from storage when the cache doesn't have it. Files are cached
for a day rather than a year, and release.sh takes only versions like
1.9 or 1.9.1 and won't put up a version the bucket already has. The
responses also carry the site's HSTS and nosniff headers.
A range storage can't serve, or a resume on a file that changed, now
gets the whole file instead of a trip to GitHub, and a failing cache
falls through to storage. Only plain downloads fill the cache.
release.sh now refuses a version the appcast already offers rather
than one the bucket has, so a release that stopped part way can be run
again, and a Wrangler hiccup can't let a file be replaced.
@kewonit
kewonit merged commit 77af3a7 into main Nov 21, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant