kamsar / Dianoga

An automatic image optimizer for the Sitecore media library.
Other
104 stars 45 forks source link

Webp Images are Not Serving When Azure CDN is Enabled #117

Closed jason-booth closed 2 years ago

jason-booth commented 2 years ago

Version of Dianoga

6.0.1

Environment description

Scaled Sitecore 9.2, SXA, Hosted on Azure (Sitecore Managed Cloud)

What configs you have enabled

Web.config: add verb="*" path="sitecore_media.ashx" type="Dianoga.NextGenFormats.MediaRequestHandlerXA, Dianoga" name="Sitecore.MediaRequestHandler"

Reproducible steps (1... 2... 3...) that cause the issue

This issue is only seen when on a our scaled environments that use the Azure CDN. The issue is not seen on dev environments that don't use the CDN. I suspect this might not be a Dianoga issue but instead an Azure CDN issue. In some research, I see that Azure CDN does not return the "Accept" header. When looking at a single image request in Chrome Dev Tools, I see "Accept" in the request headers (value: "image/avif,image/webp,image/apng,image/svg+xml,image/,/*;q=0.8") but I do not see it in the response headers.

Additionally, this post confirms that Azure CDN does not support the "Accept" header: https://docs.microsoft.com/en-us/answers/questions/594279/azure-cdn-does-not-forward-accept-header-to-origin.html

In this environment I do not see the "webp" appended to the query string of the image requests as expected.

If Azure CDN is not respecting/returning the "Accept" header, can you confirm that would cause this issue I am seeing?

What you expected to see, versus what you actually saw

Browsers are not receiving webp images as expected.

Relevant logs

Nothing in the Dianoga logs or Sitecore logs to indicated errors. I do see optimizations taking place as expected in Dianoga logs. I can see those optimized images being served by matching download size in Chrome Dev Tools to the optimized size reported in the log.

jason-booth commented 2 years ago

Attachment showing headers for an image request.

Headers
markgibbons25 commented 2 years ago

Hi Jason please see https://github.com/kamsar/Dianoga/issues/113#issuecomment-1178063232