In server rewrite mode, the same image URL returns AVIF, WebP or the original depending on the browser. A CDN has to keep those versions apart using the Vary: Accept header. Many CDNs ignore it and cache whichever version they saw first.
InfoThe simple fix: switch to picture tags under Settings → Delivery. Each format then has its own URL and every CDN caches it correctly.
Cloudflare
Cloudflare free and pro plans ignore Vary: Accept for images. Use picture tags. On Enterprise plans, Vary for images can be turned on in the Cache settings.
Other CDNs
- BunnyCDN: turn on Vary Cache: AVIF/WebP in the pull zone, or use picture tags.
- KeyCDN, StackPath and most others: use picture tags.
- After any change, purge the whole CDN cache and run the delivery test again.