Our website automatically serves WebP images to browsers that support them and regular PNG or JPEG images to browsers that don’t. We’ve run into an issue while using cloudflare caching that is the WebP image being served to Safari 14 on macOS Catalina, which doesn’t support WebP images, although the same version of safari supports WebP images when running on macOS Big Sur.
With development mode on, our website works correctly, serving PNG images to macOS Catalina and WebP images to macOS Big Sur. When we turn on caching, cloudflare doesn’t make a distinction between those two and serves the WebP image incorrectly.
We believe the configuration is correct on our side, and find it strange the CF cache returns a WebP image when the browser doesn’t include it on the Accept header.
We’re using Wordpress with Cloudflare APO enabled and cloudflare plugin installed. We use the WebP Converter for Media plugin to handle WebP images.
Uncached Request and Response headers:
Request
Accept: image/png,image/svg+xml,image/*;q=0.8,video/*;q=0.8,*/*;q=0.5
Accept-Encoding: gzip, deflate, br
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.2 Safari/605.1.15
Response
:status: 200
Content-Type: image/png
X-Frame-Options: SAMEORIGIN
Date: Thu, 14 Jan 2021 13:25:32 GMT
Content-Length: 165378
ETag: "28602-5b3705fae633a"
Accept-Ranges: bytes
Last-Modified: Fri, 06 Nov 2020 13:41:46 GMT
cf-request-id: 07a2abb1f90000dbc4cb3aa000000001
Server: cloudflare
cf-cache-status: DYNAMIC
expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
Strict-Transport-Security: max-age=2592000; includeSubDomains
cf-ray: 6117aefccac7dbc4-GIG
Cached Request and Response headers:
Request
Accept: image/png,image/svg+xml,image/*;q=0.8,video/*;q=0.8,*/*;q=0.5
Accept-Encoding: gzip, deflate, br
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.2 Safari/605.1.15
Response
:status: 200
Content-Type: image/webp
Vary: Accept,Referer,X-Forwarded-Proto, Accept-Encoding
ETag: "468a-5b3705fbb24c3"
Age: 2738
Cache-Control: max-age=14400
Date: Thu, 14 Jan 2021 13:22:03 GMT
Content-Length: 18058
Accept-Ranges: bytes
X-Frame-Options: SAMEORIGIN
Last-Modified: Fri, 06 Nov 2020 13:41:47 GMT
Server: cloudflare
cf-request-id: 07a2a880850000dbc4ba0e1000000001
cf-cache-status: HIT
expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
Strict-Transport-Security: max-age=2592000; includeSubDomains
cf-ray: 6117a9e0ddeadbc4-GIG