Currently Cloudflare CDN cache doesn’t seem to support HTTP Vary header as per https://support.cloudflare.com/hc/en-us/articles/115003206852
vary
Cloudflare cache doesn’t respect the vary header
This means if you’re on Cloudflare free plan without access to Polish’s webP support, you can not properly implement webP support on origin server side as Cloudflare CDN cache won’t be able distinguish whether Safari web browsers will serve non-webP images from origin server as Cloudflare CDN cache may have previously cached a webP mime-typed served image to webP supported browser visits from Chrome/Firefox.
End result is on Cloudflare CDN cached .webp origin images get served to web browsers that do not support webP i.e. Safari. Example of the issue is outlined at WebP & Safari Browsers - any suggestions?
Right now I have had to disable Nginx origin webP support if Cloudflare is detected for sites because of this as outlined at https://centminmod.com/webp/.
map $http_accept $webpok {
default 0;
"~*webp" 1;
}
map $http_cf_cache_status $iscf {
default 1;
"" 0;
}
map $webpok$iscf $webp_extension {
11 "";
10 ".webp";
01 "";
00 "";
}
So Nginx only enables webP origin support if Cloudflare cache is not detected and browser HTTP request headers support image/webp mime type and disable webP origin support when Cloudflare cache is detected.
This is mainly an issue with Cloudflare free plan as paid plans have Polish webP support.
So suggestion/request is for Cloudflare CDN cache to support HTTP Vary header if possible.