Hosting a 2 GB PC game on Cloudflare R2: 32 MB to the main menu
A hard drive answers a read in a few milliseconds; a server far away answers in tens. The game does not know the difference, and it reads a lot. Three things make that work over the internet.

The whole game, music included
The public pack is about 2 GB: the recompiled program, the game's data, every licensed song and the movies. Nothing is cut. The program, speed.wasm, is 70 MB and travels as 11.1 MB of brotli. A cold first visit reaches the game's main menu after 32.6 MB in 108 requests; tracks and cars arrive when the game asks for them.
Where it is hosted
- Cloudflare R2 holds the files. Downloads from R2 cost nothing, which matters for a 2 GB game.
- Three response headers (
Cross-Origin-Opener-Policy,Cross-Origin-Embedder-Policy,Cross-Origin-Resource-Policy) turn on cross-origin isolation, which the browser requires before it shares memory between the game's threads. - Pages and scripts are never cached at the edge; game data is cached for a day. Scripts carry the build number in their address, so a new build never mixes with an old one.
Why it loads fast
- Pieces cut to the game's reads. The reads the game always makes are stored as 473 brotli-compressed pieces, each exactly one read. The browser fetches a piece and unpacks it on the way in; any other read is a plain byte range.
- Small files come whole. A file up to 8 MB is fetched in one request on its first read and kept, so its next reads cost no round trip.
- Prefetch. A list of what the game opens on the way to the menu and the first race lets helper threads fetch those files before the game asks.
The loader is host/files.c and the pieces are cut by tools/data_chunks.py. To see the result, open the game.
In the repo: host/files.c · tools/build_public.py · tools/data_chunks.py · docs/re/hosting.md