用于jQuery或Google CDN的Microsoft CDN? [英] Microsoft CDN for jQuery or Google CDN?

查看:162
本文介绍了用于jQuery或Google CDN的Microsoft CDN?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您使用哪个CDN链接到您的jquery文件或任何javascript文件实际上是否重要。一个人可能比另一个人更快吗?还有哪些其他因素可以起到决定使用哪种cdn的作用?我知道微软,雅虎和谷歌现在都有CDN。

Does it actually matter which CDN you use to link to your jquery file or any javascript file for that matter. Is one potentially faster than the other? What other factors could play a role in which cdn you decide to use? I know that Microsoft, Yahoo, and Google all have CDN's now.

推荐答案

根据评论更新:

简短版本这并不重要,但可能取决于他们托管的内容。他们都有不同的东西:谷歌没有托管jQuery.Validate,微软没有托管jQuery-UI,自2016年以来他们做!!,微软提供的脚本本来可以通过 ScriptResource.axd 和更容易的整合(例如使用ASP.Net 4.0的ScriptManager

Short version: It doesn't matter much, but it may depend on what they host. They all host different things: Google doesn't host jQuery.Validate, Microsoft did not host jQuery-UI, since 2016 they do!!, Microsoft offers their scripts that would otherwise be served via ScriptResource.axd and an easier integration (e.g. ScriptManager with ASP.Net 4.0).

重要提示:如果你正在建设内联网应用程序,远离CDN方法。无论谁托管它都没关系,除非你内部的非常超载服务器,没有CDN会给你比本地100mb / 1GB以太网更多的性能。如果您使用CDN进行严格的内部应用,则会影响性能正确设置缓存过期标头并忽略CDN中存在的CDN仅限内联网的情况。

Important Note: If you're building an intranet application, stay away from the CDN approach. It doesn't matter who's hosting it, unless you're on a very overloaded server internally, no CDN will give you more performance than local 100mb/1GB ethernet will. If you use a CDN for a strictly internal application you're hurting performance. Set your cache expiration headers correctly and ignore CDNs exist in the intranet-only scenario.

被阻止的可能性似乎大致相等,几乎为零。我曾经合作过这种情况并非如此,但这似乎是一个例外。此外,由于此答案的原始发布,其周围的上下文发生了很大变化,Microsoft CDN取得了很大进展。

The chances of either being blocked seems to be about equal, almost zero. I have worked on contracts where this isn't true, but it seems to be an exception. Also, since the original posting of this answer, the context surrounding it has changed greatly, the Microsoft CDN has made a lot of progress.

我目前正在进行的项目使用两种最适合我们解决方案的CDN。有几个因素影响到这一点。拥有旧浏览器的用户仍可能每个域同时发出2个请求根据HTTP规范的建议。对于任何运行任何新版本的支持流水线操作(每个当前浏览器),这都不是问题,但基于另一个因素,我们也在敲除这个限制,至少就javascript而言。

The project I'm currently on uses both CDNs which works best for our solution. Several factors play into this. Users with an older browser are still probably making 2 simultaneous requests per domain as recommended by the HTTP specification. This isn't an issue for anyone running anything decently new that supports pipelining (every current browser), but based on another factor we're knocking out this limitation as well, at least as far as the javascript.

谷歌的CDN我们用于:

Google's CDN we're using for:

  • jquery.min.js
  • jquery-ui.min.js.

我们正在使用的Microsoft的CDN:

Microsoft's CDN we're using for:

  • MicrosoftAjax.js
  • MicrosoftAjaxWebForms.js (until 4.0 we're not completely removing all UpdatePanels)
  • jQuery.Validate.min.js

我们的服务器:


  • Combined.js?v = 2.2.0.6190(Major.Minor.Iteration.Changeset)

由于我们的构建过程的一部分是组合和缩小所有自定义javascript,我们通过自定义脚本管理器执行此操作,该脚本管理器包括这些脚本的发布或调试(非缩小)版本,具体取决于构建。由于Google没有托管jQuery验证包,因此这可能是一个缺点。 MVC在其2.0版本中包含/使用它,因此您可以完全依赖Microsoft的CDN来满足您的所有需求,并通过ScriptManager自动完成所有

Since part of our build process is combining and minifying all custom javascript, we do this via a custom script manager that includes the release or debug (non-minified) versions of these scripts depending on the build. Since Google doesn't host the jQuery validation package, this can be a down-side. MVC is including/using this in their 2.0 release, so you could rely completely on Microsoft's CDN for all your needs, and all of it automatic via the ScriptManager.

唯一要做的其他论点是DNS时间,在页面加载速度方面存在成本。 平均值仅仅因为它的使用时间更长(它已经存在更长时间) ajax.googleapis.com 很可能早于<$返回DNS c $ c> ajax.microsoft.com ,只是因为本地DNS服务器更有可能获得它的请求(这是区域惩罚中的第一个用户)。这是一个非常次要的事情,只有在性能非常重要时才应考虑,直到毫秒。

(是的:我意识到这一点与我的相反使用两个CDN,但在我们的情况下,DNS时间远远超过javascript /阻塞发生时的等待时间)

The only other argument to be made would be DNS times, there is a cost to this in terms of page load speed. On Average: Simply because it's used more (it's been around longer) ajax.googleapis.com is likely to be returned by DNS sooner than ajax.microsoft.com, simply because the local DNS server was more likely to get a request for it (this is a first user in the area penalty). This is a very minor thing and should only be considered if performance is extremely important, down to the millisecond.
(Yes: I realize this point is contrary to my using both CDNs, but in our case the DNS time is far overshadowed by the wait time on the javascript/blocking that occurs)

最后,如果你避风港看着它,其中一个最好的工具是 Firebug ,还有一些插件:< a href =http://getfirebug.com/ =nofollow noreferrer> Page Speed 和 YSlow的。如果您使用CDN,但由于没有缓存标题,您的页面每次都会请求图像,那么您就会错过这种低调的结果。 Firebug的Net面板可以快速为您的页面加载时间提供快速细分,而Page Speed / YSlow可以提供一些很好的建议来帮助您。

Last, if you haven't looked at it, one of the best tools out there is Firebug, and some plug-ins for it: Page Speed and YSlow. If you use a CDN but your pages are requesting images every time because of no cache-headers, you're missing the low-hanging fruit. Firebug's Net panel can quickly give you a quick breakdown of your page load-time, and Page Speed/YSlow can offer some good suggestions to help.

这篇关于用于jQuery或Google CDN的Microsoft CDN?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆