Conversion

Images are automatically converted to modern formats based on the browser's Accept header. No query parameter is needed - the worker picks the best format the client supports.

Comparison

Original PNG Converted to AVIF
Original (PNG): 1600 KB Converted (AVIF): 400 KB

Format priority

The worker inspects the Accept header and selects the best supported format:

Format Priority
AVIF Preferred when the client sends image/avif and the image fits within the pixel limit
WebP Used when AVIF is unsupported or exceeds the pixel limit
Original Served as-is when neither format is accepted

AVIF pixel limit

AVIF encoding is memory-intensive. Images larger than 5 million pixels (e.g. 2500 × 2000) automatically fall back to WebP to stay within the 128 MB Worker memory limit.

Fallback chain

If encoding fails at any stage, the worker retries with the next format rather than returning an error:

AVIF encoding fails → retry as WebP → serve original image

This guarantees a valid image is always returned. The X-Cache: BYPASS header indicates the original was served due to a processing failure.

SVG passthrough

SVG images are never converted. They are served directly from the origin without any transformation.

How it works

Browser sends:  Accept: image/avif, image/webp, image/*
Worker checks:  AVIF supported? → within pixel limit? → encode AVIF
                WebP supported? → encode WebP
                else → serve original