Caching

Transformed images are cached in Cloudflare R2 so subsequent identical requests skip the origin fetch and image processing entirely.

Cache key

The cache key is built from the output format, URL path, and query string:

{format}{pathname}{search}

// Example:
avif/photos/hero.jpg?w=800&quality=80

Cache behavior

Observability

Every response includes an X-Cache header:

X-Cache: HIT   // served from R2
X-Cache: MISS  // fetched and processed from origin

Cache duration

Cached responses include Cache-Control: public, max-age=86400 (24 hours).