kamsar / Dianoga

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

webp content-type not returned when CDN enabled #110

Closed kwyc closed 2 years ago

kwyc commented 2 years ago

Version of Dianoga

5.2.0

Environment description

Production Sitecore 9.3

What configs you have enabled

Production CD:

Dianoga.DisableForSites.config Dianoga.Jpeg.config Dianoga.Png.config Dianoga.Strategy.GetMediaStreamSync.config Dianoga.WebP.CDN.config Dianoga.WebP.config

Production CM:

Dianoga.DisableForSites.config Dianoga.Jpeg.config Dianoga.Png.config Dianoga.Strategy.MediaCacheAsync.config Dianoga.WebP.config

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

Load CDN site vs non-CDN site and check content-type on .webp images. Expect image/webp instead of image/jpeg.

What you expected to see, versus what you actually saw

On CD, when CDN is enabled, image Expected to see image/webp instead of image/jpeg.

On CM, when CDN is disabled, image image/webp is returned which is correct behaviour.

GenerateCacheKey orders seems correct.

Relevant logs

N/A

Also is latest Dianoga 5.4.1 compatible with Sitecore 9.3?

markgibbons25 commented 2 years ago

You need to be on at least 5.3, but I'd recommend trying the 6.0 release. All compatible with Sitecore 9.3

kwyc commented 2 years ago

Thank you, we will give 6.0 a try!

kwyc commented 2 years ago

@markgibbons25

Hi Mark, we have upgraded from V5 to 6; however, the issue with CDN still persists after enabling "Dianoga.NextGenFormats.CDN.config", where images return now have "?extension" appended after them and the header still shows "image/jpg" where we expect "image/webp".

Network: ../hp_hero_spring.jpg?extension= ../ic_art_moves.png?extension

Since we don't want "?extension" to appear, we have temporarily commented off the "mediaLibrary" node within "Dianoga.NextGenFormats.CDN.config" so the extension query string is not added.

Commented off, `

        <mediaProvider
            type="Dianoga.NextGenFormats.MediaProvider, Dianoga"
            patch:instead="mediaProvider[@type='Sitecore.Resources.Media.MediaProvider, Sitecore.Kernel']"/>
    </mediaLibrary>`

Which means we are back to square one (before V6 upgrade), where "image/webp" header is not returned when CD URL is behind CDN. CM URL is fine as it is not behind CDN, so "image/webp" header is returned correctly. Do you have any other recommendations to take?

Thanks!