SITECORE- WebP图像未使用Dianoga工具从CDN生成

发布于 2025-02-13 09:25:18 字数 708 浏览 4 评论 0 原文

Dianoga的版本 5.4.1

环境描述 sitecore.net 9.3.0 。

  • dianoga.webp.config

web.config更改: 我已在sitecore_media.ashx type中取代为“ dianoga.mediarequesthandler,dianoga” name =“ sitecore.mediarequesthandler”

您期望看到的,而您实际看到的

查看以WebP格式拉下的图像

实际:图像以原始格式收到(JPEG,PNG,等),但不在WebP中。

日志文件: 所有日志文件都是空的。

评论 在Azure MediaProvider中部署在CD上后,将扩展WebP添加为URL参数。这应该在MediaRequestHandler中触发WebP优化器。但是MediaProvider似乎没有运行。在当地的环境中,我不使用CDN,而Dianoga可以正常工作。我可能缺少什么?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

森林迷了鹿 2025-02-20 09:25:18

•您的映像文件没有被转换,因为同步/异步策略中可能存在 冲突 。另外,由于CDN中的'dianoga.webp.cdn.config'配置已启用,因此您必须禁用'dianoga.strategy.mediacacheasync。配置'设置。

另外,通过启用'dianoga.strategy.getMediastreamsync.config.disabled'配置'config 和上面所述的'dianoga.strategy.getMediastreamsync.config.disabled and of 'media -optimatization'。这将确保当请求图像时,优化将同步发生,从而确保成功转换图像文件。

•请检查'Accept'在CDN中配置的标头将包含在缓存键中,因为此标头中提到了接受媒体格式的列表。该标头告诉可能哪种图像格式转换。例如: - 标题可以为'image/avif,image/webp,image/apng,image/*,*/*; q = 0.8',这意味着浏览器支持“ webp'image格式

另外,正如您在问题中所指出的那样,您似乎已启用 '下一代格式支持' ,但在那也是如此您将必须在 web.config文件中将'''''''''''''''''''''''更改。

有关更多详细信息,请参考以下文档链接以获取有关此以下的更多步骤: -

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

• 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

醉酒的小男人 2025-02-20 09:25:18

如果您使用的是Azure CDN(Microsoft)或Azure前门经典,带有Azure CDN(Microsoft), Accept 标题未传递给原始服务器。 Dianoga需要接受标题以了解它是否支持NextGen Image格式。

如果未通过Azure CDN路由页面,则 Accept 标题将仅传递给Origin Server,仅用于页面请求。 Dianoga和Sitecore将使用Extension查询参数 Extension = WebP,{其他Image Formats} 生成媒体链接。如果此查询参数可用,则Dianoga将能够生成 webp 格式,而无需阅读 cocept 媒体请求的标题。

选项1 :将Azure CDN升级到Verizon Premium(昂贵),并将标头传递回Origin Server,Dianoga将能够优化并发送 WebP 图像。

选项2 :如果您的CDN中有规则引擎,请创建一个规则以将Accept标头发送给其他标头名称,并在Dianoga中使用该标头名来生成 webp 格式。这需要规则引擎在请求达到Azure CDN之前。
选项,以使用azure cdn 启用WebP格式

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

爱人如己 2025-02-20 09:25:18

因此,我刚刚用CDN在我的Sitecore环境中实施了此功能,真是太棒了!这些是我的步骤:

上面的图像链接是一个屏幕快照,它具有您需要在CDN中创建的规则的参数。默认情况下,CustomAccept是Dianoga所说的自定义标头。该值是在您的CDN配置中设置的,您可以将其更改为任何想要的或离开它,都不重要。唯一重要的是,配置中的设置值匹配您在CDN规则中的目标。

如果您有任何疑问,除此之外,真正帮助我的事情实际上是在Dianoga的Github页面上阅读了Readme。 请回答您的其余问题(以及图像链接上方链接的文章),

如果您在没有CDN的情况下执行此操作, 请确保在应用程序数据中删除MediaCache文件夹。 Dianoga在他们的GitHub页面上的步骤中谈到了这一点。由于Sitecore从缓存中拉出,即使WebP可以工作并已创建,它也会将图像拉到那里。您必须擦拭它,以便WebP是其中唯一的东西。如果您使用CDN,则不必担心这一点,也许最糟糕的是擦拭CDN缓存。

So I just implemented this on my Sitecore environment with a CDN and it's awesome! These are my steps:

The image link above is a screenshot that has the parameters of the rule you need to create in your CDN. By default CustomAccept is what Dianoga calls the custom header. That value is set in your CDN config and you can change it to whatever you want or leave it, doesn't matter. The only thing that matters is that the setting value in your config matches what you target in your CDN rule.

If you have any questions beyond this what really helped me is actually reading the readMe on Dianoga's github page. That should answer the rest of your questions (as well as the article linked above the image link)

IF YOU'RE DOING THIS WITHOUT A CDN MAKE SURE TO DELETE THE MEDIACACHE FOLDER IN APP DATA. Dianoga talks about this in their steps on their github page. Since sitecore pulls from cache, it will pull images already there even if webP works and gets created already. You have to wipe it so that webP is the only thing in there. If you use a CDN you don't have to worry about this and maybe the worst is wiping your CDN cache.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文