Worker Image CDN

A Cloudflare Worker that acts as an image CDN proxy. It fetches images from an origin server, automatically converts them to modern formats, resizes on the fly, and caches the results in R2.

Features

How it works

Request → Check R2 cache → [HIT]  → Serve cached image
                        → [MISS] → Fetch from origin
                                  → Resize (if requested)
                                  → Convert to AVIF/WebP
                                  → Store in R2
                                  → Serve image

Quick start

npm install
npx wrangler r2 bucket create worker-cdn-images
npm run dev

Then request an image:

http://localhost:8787/photo.jpg?w=800&quality=80