incubator-pagespeed-ngx icon indicating copy to clipboard operation
incubator-pagespeed-ngx copied to clipboard

webp + cloudflare = images dont load on Safari

Open benslaney opened this issue 8 years ago • 10 comments
trafficstars

If you use pagespeed with the default settings it seems that it will convert .jpg to .webp and serve that to capable browsers.

However if you use CloudFlare then it will always serve .web files to CloudFlare, who will then cache the webp image, and serve that to Safari/Firefox users. Since those browsers don't support the format, the images will not get displayed. The only solution I know of is to turn image recompression off.

benslaney avatar Mar 10 '17 23:03 benslaney

I wonder, is the html being cached at CloudFlare?

oschaaf avatar Mar 11 '17 19:03 oschaaf

Ah yes, it is. it’s set to “cache everything” as a page rule. I should have thought to mention that sorry.

benslaney avatar Mar 11 '17 21:03 benslaney

I am afraid that caching html like that is probably not going to interact well with ngx_pagespeed.

There is the downstream caching feature for that [1]. But that was designed for a caching proxy running in front of your webserver - and not CloudFlare.

[1] https://modpagespeed.com/doc/downstream-caching

oschaaf avatar Mar 11 '17 21:03 oschaaf

It should still be possible to use ngx_pagespeed in OptimizeForBandwidth https://modpagespeed.com/doc/optimize-for-bandwidth mode with Cloudflare caching html in front. Or you could set CloudFlare to respect the Vary:User-Agent header that PageSpeed puts on its HTML responses in CoreFilters https://modpagespeed.com/doc/config_filters mode. You can experiment with whichever choice gives you the best performance.

On Mar 11, 2017 4:45 PM, "Otto van der Schaaf" [email protected] wrote:

I am affraid that caching html like that is probably not going to interact well with ngx_pagespeed.

There is the downstream caching feature for that [1]. But that was designed for a caching proxy running in front of your webserver - and not CloudFlare.

[1] https://modpagespeed.com/doc/downstream-caching

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/pagespeed/ngx_pagespeed/issues/1392#issuecomment-285902572, or mute the thread https://github.com/notifications/unsubscribe-auth/AB2kPf_kaMYECXbozHArPTdVJncQ30GCks5rkxYPgaJpZM4MZ94W .

jmarantz avatar Mar 12 '17 12:03 jmarantz

Or you could set CloudFlare to respect the Vary:User-Agent header

@jmarantz How can this be done?

dmatora avatar Jan 27 '19 08:01 dmatora

https://www.modpagespeed.com/doc/configuration#respectvary

@Lofesa is that related to my question?

dmatora avatar Jan 27 '19 09:01 dmatora

Or you could set CloudFlare to respect the Vary:User-Agent header

@jmarantz How can this be done?

Yes, I think, is the directive in config to respect the Vary header. As stated in the doc: " If a site has resources that legitimately vary on User-Agent, or on some other attribute, then in order to preserve that behavior, you must add

Apache:

ModPagespeedRespectVary on

Nginx:

pagespeed RespectVary on;

to your configuration file."

Lofesa avatar Jan 28 '19 09:01 Lofesa

@Lofesa unless I am missing something, this sets pagespeed to respect the Vary:User-Agent header But CloudFlare will still not respect it. And based on this https://community.cloudflare.com/t/vary-user-agent-ignored/23988 CloudFlare can only be configured to respect Vary:User-Agent on enterprise plan. So far the only option that works is to just disable cloud flare cache (surprisingly in my case that made performance better)

dmatora avatar Jan 28 '19 09:01 dmatora

Hi @dmatora Sorry, I missreading. I was thinking that the respect vary was in pagespeed not cloudflare

Lofesa avatar Jan 29 '19 12:01 Lofesa