I built Cloudflare Images in PHP (to scale & compress images) @aarondfrancis
I built Cloudflare Images in PHP (to scale & compress images)  @aarondfrancis
Uploaded April 2025 | Updated September 2026, 1 minute ago
Prefer to read instead of watch? Here you go! aaronfrancis.com/2025/a-cookieless-cache-friendly-image-proxy-in-laravel-inspired-by-cloudflare-9e95f7e0.

In this video I built a very basic version of Cloudflare's image proxy that we use on our various sites, like highperformancesqlite.com. It's a single controller in our Laravel application!

Cloudflare Images: cloudflare.com/developer-platform/products/cloudflare-images
Intervention: image.intervention.io/v3

Follow me:
Twitter: twitter.com/aarondfrancis
LinkedIn: linkedin.com/in/aarondfrancis
Website: aaronfrancis.com - find articles, podcasts, courses, and more.

Chapters:
00:00 - What we’re building: Cloudflare-style image transforms in Laravel
00:59 - Defining the route with dynamic options and path
02:41 - Writing regex constraints for the route
03:56 - Creating the image controller
05:01 - Verifying the image exists
06:40 - Installing and using Intervention Image
07:15 - Parsing the options from the URL
08:45 - Transforming options into a usable array
09:13 - Scaling and manipulating the image
10:00 - Supporting format and quality options
11:58 - Encoding the image with format and quality
13:17 - Returning the image with proper headers
14:49 - Adding cache-control headers for CDN caching
15:59 - Preventing cookies from disabling CDN caching
18:59 - Creating middleware to strip cookies
20:56 - Implementing simple rate limiting
22:32 - Gracefully handling rate limit errors
24:07 - Wrapping up: why this approach works for us
I built Cloudflare Images in PHP (to scale & compress images)The Music Makers Podcast - 004 - Do The Work.The Music Makers Podcast - 008 - Entreporn: The Fallacy That Wastes Your LifeRuby on Rails + SQLite with Stephen MargheimBuilding a Life OSAutomating my life (or at least the boring parts)The Music Makers Podcast - 010 - Most People WontThe Music Makers Podcast - 013 - Tomorrow Is Not A Suitable Day For Doing ThingsLaravel + Livewire todo app (and so much more)Customizing Laravel PulseThe Music Makers Podcast - 003 - Luck Surface Area, or How To Create Luck.Production SQLite with Turso and libSQL
Aaron Francis |

I built Cloudflare Images in PHP (to scale & compress images)

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER