r/audiobookshelf • u/feetthatstink • 1h ago
I built a $0/mo Cloudflare Worker + R2 + HTTP/3 (QUIC) edge-caching front door for Audiobookshelf — looking for beta testers!
I love self-hosting Audiobookshelf at home, but running it over a residential upload connection had two annoying pain points for me:
- Slow browsing/covers when scrolling through the library away from home.
- Stream drops when switching networks (Wi-Fi ↔ 5G/LTE) — walking out the front door changes your phone's IP and kills the TCP stream to your home server.
I didn't want to pay to host ABS in the cloud or upload my entire multi-TB library to cloud storage. Then I realized: you only listen to 1–3 books at a time.
So I built abs-edge-cache, an open-source Cloudflare Worker that sits in front of your existing Audiobookshelf server (e.g., behind a Cloudflare Tunnel) and turns Cloudflare's global edge into a smart caching layer—while keeping your full library on your home server.
What it does
- HTTP/3 (QUIC) audio streaming: Native players (AppleCoreMedia, ExoPlayer, browsers) stream over QUIC so Wi-Fi ↔ cellular handoffs migrate mid-stream without dropping—and it automatically falls back to HTTP/2 or HTTP/1.1 on any device or network that doesn't support QUIC.
- Smart R2 audio caching (sliding window): Pressing Play warms the active chapter and upcoming chapters (WARM_WINDOW_TRACKS) into Cloudflare R2 in the background, serving 206 byte-range requests from the nearest edge POP. Finished books are automatically evicted from R2, and hitting Download only uses R2 if the book is already cached (never wastes R2 space on local downloads).
- Instant edge-cached UI & metadata: Covers, static Web UI assets, RSS feeds (/feed/:slug), and library/progress JSON are cached at Cloudflare's edge with instant invalidation on edits or progress syncs.
- Offline-origin resilience: If your home server reboots or your tunnel drops temporarily, cached reads fall back to STALE-IF-ERROR, and listening progress writes (/sync, /close, PATCH /progress) are queued and automatically replayed as soon as your server comes back online.
- Built-in R2 Free-Tier Circuit Breaker (FREE_TIER_GUARD): Enabled by default to cap storage at 9.0 GB (with oldest-book LRU eviction) and Class A/B ops at 80% of Cloudflare R2's free tier so you never get a surprise bill (or set FREE_TIER_GUARD="no" if you use paid R2).
- Security: Scanner/bot blocker, edge login brute-force rate limiting, device/country session locking, and optional HS256 JWT signature verification (VERIFY_JWT).
Looking for Beta Testers!
So far I've tested this thoroughly with Absorb on iOS, and it's been rock solid. I'd love feedback and bug reports from anyone willing to test it with:
- Official Audiobookshelf app (iOS & Android)
- Plappa / ShelfPlayer
- Web UI / RSS podcast clients
It includes a 1-click "Deploy to Cloudflare" button in the README (plus full manual Wrangler instructions and a unit test suite):
GitHub: https://github.com/binyaminyblatt/abs-edge-cache
Would love to hear how it behaves on your setup or if you run into any client quirks!