— Lab · 2026 · PHP · cURL · WebP

PHP image proxy with WebP negotiation

A 30-line PHP proxy that fetches images from a headless CMS, negotiates WebP via Accept header, and caches them with 30-day immutable headers. The whole thing fits in a single file.

All lab
Year
2026
Stack
PHP
cURL
WebP
Cloudflare
Source
GitHub
PHP image proxy with WebP negotiation

The site you're reading runs on plain PHP, OVH shared hosting and a headless Cockpit install. The image API on Cockpit is private — requires an api-key. The browser can't carry that key.

The proxy sits in between. Client hits /api/img.php?id=X&w=800. PHP fetches from Cockpit with the server-side key, negotiates WebP if the browser advertises it, and streams the result with 30-day immutable cache headers. Cloudflare picks up the cache, browsers cache locally, the CMS never sees the same request twice.

Useful when: you're on shared hosting, you want resized + format-negotiated images, you don't want to expose a CMS API key in client code.

— Next steps

Tell us what was only ever described.

Start a build

or write to info@amplifiedcreations.com · a senior member of the team answers