skip to Main Content

Version of Dianoga
5.4.1

Environment description
Sitecore.NET 9.3.0
.NET Framework 4.7.2

What configs you have enabled

  • Dianoga.DisableForSites.config
  • Dianoga.Jpeg.config
  • Dianoga.Log.config
  • Dianoga.Png.config
  • Dianoga.Svg.config
  • Dianoga.WebP.CDN.config
  • Dianoga.WebP.config

Web.config changes:
I`ve replaced in sitecore_media.ashx type to "Dianoga.MediaRequestHandler, Dianoga" name="Sitecore.MediaRequestHandler"

What you expected to see, versus what you actually saw

Expected: To see images being pulled down in webp format

Actual: Images are received in original formats (jpeg, png, etc), but not in webp.

Logs files:
All logs files are empty.

Comments
After deploy on CD in Azure MediaProvider adds extension webp as a URL param. This should trigger the webp optimizer in the MediaRequestHandler. But the MediaProvider doesn’t appear to run. On my local envirement I don`t use CDN and Dianoga works fine. And I am probably missing something?

2

Answers


  1. • Your image files are not getting converted because there might be a conflict in the Sync/Async strategy. Also, since the ‘Dianoga.WebP.CDN.config’ configuration in the CDN is enabled, you will have to disable the ‘Dianoga.Strategy.MediaCacheAsync.config’ setting.

    Also, ensure that ‘MediaOptimization’ is enabled by enabling the ‘Dianoga.Strategy.GetMediaStreamSync.config.disabled’ config setting and the one stated above. This will ensure that the optimization will occur synchronously when the images are requested, thus ensuring the successful conversion of image files.

    • Please check the ‘Accept’ header configured in the CDN to be included in the cache key as the list of accepted media formats is mentioned in this header. This header tells which image format conversions are possible. For e.g.: – the header can be ‘image/avif,image/webp,image/apng,image/*,*/*;q=0.8’ which means that the browser supports ‘WebP’ image format.

    Also, as stated by you in the question, you seem to have enabled the ‘Next-gen formats support’, but in that too, you will have to change the line ‘’ to ‘’ in the web.config file.

    For more details, kindly refer to the below documentation link for more steps to be followed regarding this: –

    https://github.com/kamsar/Dianoga#optimization-strategies

    Login or Signup to reply.
  2. If you are using Azure CDN (Microsoft) or Azure Front Door Classic with Azure CDN (Microsoft), Accept header is not passed to the Origin server. Dianoga needs Accept header to understand whether it supports nextgen image formats or not.

    If the pages are not routed via Azure CDN, then Accept header will be passed to the origin server only for the page requests. Dianoga and Sitecore will generate the media link with Extension query param extension=webp,{other image formats}. If this query param is available, then Dianoga will be able to generate the webp format without reading the Accept header of media request.

    Option 1: Upgrade Azure CDN to Verizon Premium (costly) and it passes the header back to Origin server and Dianoga will be able to optimize and send the webp Images.

    Option 2: If you have a rule engine in your CDN, create a rule to send the Accept header in a different header name and use that header name in Dianoga to generate the webp format. This needs a rule engine before the requests hit the Azure CDN.
    Option to enable webp format using Azure CDN

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search