kamsar / Dianoga

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

Webp Image not generating when azure CDN enabled (Sitecore 9.2 + JSS) #111

Closed PradeepSitecore closed 2 years ago

PradeepSitecore commented 2 years ago

Sitecore 9.2 (JSS) and Dianoga 5.3.0

With Dianoga.WebP.config enabled, I replaced JSS media handler in web.config:

with custom one:

using MediaRequestHandler = Sitecore.JavaScriptServices.Media.MediaRequestHandler;

public class JSSWebPMediaHandler : MediaRequestHandler
{
    protected override bool DoProcessRequest(HttpContext context, MediaRequest request, Media media)
    {
        if (context?.Request.AcceptTypes != null && context.Request.AcceptTypes.Contains("image/webp"))
        {
            request.Options.CustomOptions["extension"] = "webp";
        }
        return base.DoProcessRequest(context, request, media);
    }
},

Environment description

Scaled environment

What configs you have enabled

Dianoga.DisableForSites.config, Dianoga.Jpeg.config, Dianoga.Png.config, Dianoga.WebP.CDN.config , Dianoga.WebP.config, Dianoga.Svg.configDianoga.Svg.config,

What you expected to see, versus what you actually saw

expected result : Images should convert to webp format Actual result : Images are coming in same png and jpg format

In standalone environment without CDN the images are converting to webp images but in scaled environment with Azure CDN images are not converting

Relevant logs

There are relevant logs

markgibbons25 commented 2 years ago

In Azure CDN can you make sure that cache by query string is enabled?

PradeepSitecore commented 2 years ago

@markgibbons25 , Yes Its enabled. image

markgibbons25 commented 2 years ago

I'm not sure then, I haven't tested it with JSS / Azure CDN / Azure Front Door, only with CloudFlare (no JSS). I'd say its more likely an issue with JSS not having the right query string.

markgibbons25 commented 2 years ago

For Azure CDN support you'll need to upgrade to 6.1.0 and review the readme config for this.