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.WebP.CDN.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 the same png and jpg format

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

3 Answers 3


have you checked Dianoga documentation here: https://github.com/kamsar/Dianoga#optimization-strategies?

On which version of Dianoga you are? It seems you need to enable Dianoga.NextGenFormats.CDN.config:

If you run Sitecore under CDN: review and enable Dianoga.NextGenFormats.CDN.config.disabled. It will add ?extension= <list of supported extensions> query parameter to all images present on your pages.

Hope it helps!


There are 2 different ways to get this to work correctly with a CDN:

  1. Through the Accept header. Based on your question it seems like this is the approach you are trying to use. You will have to configure your CDN to properly handle the Accept header. I'm not familiar with Azure CDN but I had to configure my CDN to include this header in the cache key.
  2. Through the extension=webp query string, this is also one of the key features which Dianoga.WebP.CDN.config adds. However your custom MediaRequestHandler does not check this querystring. If this is your approach you will have to update your code in JSSWebPMediaHandler. You can use the Dianoga MediaRequestHandler as an example and see what this method call does.

Azure CDN (MS) does not forward Accept headers to the downstream servers. So you will lose the browser AcceptTypes header to add the Extension querystring to support webp. It is a limitation in Azure CDN.

Azure CDN (MS) does not forward the Accept Headers

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.