Programming

jQuery 또는 Google CDN 용 Microsoft CDN?

procodes 2020. 5. 15. 21:06
반응형

jQuery 또는 Google CDN 용 Microsoft CDN? [닫은]


실제로 jquery 파일 또는 해당 문제에 대한 javascript 파일에 연결하는 데 사용하는 CDN이 중요합니까? 하나는 다른 것보다 잠재적으로 빠릅니까? cdn을 사용하기로 결정한 다른 요인은 무엇입니까? Microsoft, Yahoo 및 Google에 CDN이 모두 있다는 것을 알고 있습니다.


의견을 기반으로 업데이트 :

짧은 버전 : 별로 중요하지 않지만 호스팅 대상에 따라 달라질 수 있습니다. 그들은 모든 호스트 다른 것들을 : 구글은 2016 년부터 그들이!, 마이크로 소프트가 제공되지 호스트 jQuery.Validate는, 마이크로 소프트가 호스트 jQuery를-UI하지 않았다 않습니다 그렇지 통해 제공 될 것이다 그들의 스크립트 ScriptResource.axd및 쉽게 통합 (예 : ASP와 스크립트 관리자. 순 4.0 ).

중요 사항 : 인트라넷 응용 프로그램을 구축하는 경우 CDN 접근 방식을 피하십시오. 당신이에 아니라면, 그것을 호스팅 누가 중요하지 않습니다 매우 내부적으로 과부하 서버, 더 CDN 당신에게 지역 100메가바이트 이상 / 1 기가 바이트 이더넷 것보다 성능을 제공하지 않습니다. 내부 응용 프로그램에 CDN을 사용하면 성능저하 됩니다. 캐시 만기 헤더를 올바르게 설정 하고 인트라넷 전용 시나리오에 존재하는 CDN은 무시하십시오.

막힐 확률은 거의 같고 거의 0 인 것 같습니다. 이것이 사실이 아닌 계약에서 일했지만 예외 인 것 같습니다. 또한이 답변을 처음 게시 한 이후로 주변 환경이 크게 바뀌면서 Microsoft CDN은 많은 진전을 이루었습니다.

현재 진행중인 프로젝트는 솔루션에 가장 적합한 두 CDN을 모두 사용합니다. 여기에는 몇 가지 요소가 있습니다. 오래된 브라우저를 사용하는 사용자 는 여전히 HTTP 사양에서 권장하는대로 도메인 당 2 개의 동시 요청을하고있을 것입니다 . 이것은 파이프 라이닝 (현재 모든 브라우저) 지원하는 괜찮은 새로운 것을 실행하는 사람에게는 문제가 아니지만 다른 요인에 따라 적어도 자바 스크립트까지는이 제한을 없애고 있습니다.

우리가 사용하는 Google의 CDN :

우리가 사용하는 Microsoft의 CDN :

우리 서버 :

  • Combined.js? v = 2.2.0.6190 (주요 사소한 반복. 변경)

빌드 프로세스의 일부는 모든 사용자 정의 자바 스크립트를 결합하고 축소하는 것이므로 빌드에 따라 이러한 스크립트의 릴리스 또는 디버그 (최소화되지 않은) 버전을 포함하는 사용자 정의 스크립트 관리자를 통해이를 수행합니다. Google은 jQuery 유효성 검사 패키지를 호스팅하지 않기 때문에 단점이 될 수 있습니다. MVC는이를 2.0 릴리스에 포함 / 사용하므로 모든 요구 사항에 대해 Microsoft의 CDN에 전적으로 의존 할 수 있으며 ScriptManager를 통해 모든 CDN에 자동으로 의존 할 수 있습니다.

다른 유일한 주장은 DNS 시간 일 것입니다. 페이지로드 속도 측면에서 이에 대한 비용이 있습니다. 평균 : 단순히 더 많이 사용 되었기 때문에 (더 오래 사용됨) 로컬 DNS 서버가 요청을받을 가능성이 높기 때문에 ajax.googleapis.comDNS보다 더 빨리 DNS에 의해 반환 될 가능성이 높습니다 ajax.microsoft.com(지역 벌금의 첫 번째 사용자). . 이것은 매우 사소한 일이며 밀리 초까지 성능이 매우 중요한 경우에만 고려해야합니다.
(예 :이 시점은 두 CDN을 모두 사용하는 것과 반대되는 것을 알고 있지만 우리의 경우 DNS 시간이 발생하는 자바 스크립트 / 차단의 대기 시간에 의해 훨씬 어두워집니다)

마지막으로, 그것을 보지 못했다면, 가장 좋은 도구 중 하나는 Firebug 및 일부 플러그인입니다 : Page SpeedYSlow . CDN을 사용하지만 캐시 헤더가 없기 때문에 페이지에서 매번 이미지를 요청하는 경우 낮은 결단력이 없습니다. Firebug의 Net 패널을 사용하면 페이지로드 시간을 빠르게 분석 할 수 있으며 Page Speed ​​/ YSlow가 도움이되는 몇 가지 좋은 제안을 제공 할 수 있습니다.


jQuery 용 Google CDN을 반드시 사용해야합니다 (이는 Microsoft 중심 개발자가 제공함).

간단한 통계입니다. jQuery에 MS CDN 사용을 고려하는 사람들은 항상 소수입니다. jQuery를 사용하는 비 MS 개발자가 너무 많아 Google을 사용하고 Microsoft를 사용하지 않을 것입니다. 공개 CDN의 큰 승리 중 하나는 캐싱이 향상 되었기 때문에 여러 CDN으로 사용을 분할하면 해당 혜택의 가능성이 줄어 듭니다.


Google은 자체 소프트웨어로 축소 된 jQuery 버전을 보내드립니다.이 버전은 MS에서 제공하는 표준 축소 버전보다 6kb 가볍습니다. Google로 이동하십시오.


한 가지 고려해야 할 것은 두 회사가 약간 다른 "추가"라이브러리를 제공한다는 것입니다.

필요에 따라 관련이있을 수 있습니다.


또한 ajax.microsoft.com은 microsoft.com 요청의 하위 도메인이므로 모든 microsoft.com 쿠키를 파일을 다시 가져 오는 데 걸리는 전체 시간에 추가하여 보냅니다.

또한 ajax.microsoft.com은 다른 웹 서버에서 사용하는 표준 압축보다 열등한 기본 IIS7 압축을 사용하고 있습니다.

http://ajax.microsoft.com/ajax/jquery/jquery-1.4.4.min.js - 33.4K

http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js - 26.5K

또한 다른 사람들이 google CDN을 언급했듯이 파일이 캐시 될 가능성이 크게 높아집니다.

따라서 Google을 사용하는 것이 좋습니다.


중요하지는 않지만 일부 A / B 테스트를 통해이를 확인할 수 있습니다. 트래픽의 절반을 한 CDN으로, 다른 절반을 다른 CDN으로 보내고 응답을 측정하기위한 프로파일 링을 설정하십시오. 하나 또는 다른 하나에 심각한 사용 불가 문제가있는 경우 쉽게 전환 할 수 있어야한다고 생각합니다.


나는 여기에서 조금 늦게 chiming하고 있다는 것을 알고 있지만, 프로덕션에서 사용하고있는 코드는 다음과 같습니다. 문제가 없었지만 마일리지가 다를 수 있습니다. 자신의 환경에서 테스트해야합니다.

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>    
<script type="text/javascript">
    !window.jQuery && document.write('<script src="/scripts/jquery-1.4.2.min.js"><\/script>')
</script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.4/jquery-ui.min.js" type="text/javascript"></script>
<script type="text/javascript">
    !window.jQuery.ui && document.write('<script src="/scripts/jquery-ui-1.8.2.min.js"><\/script>')
</script> 

이 통계에 관하여 : jquery.com이 구글에서 jQuery를로드합니다. 그리고 Twitter, Stackoverflow 및 기타 많은 것들도 마찬가지입니다. 따라서, 귀하의 웹 사이트 사용자가 이미 캐시했을 가능성이 매우 높습니다 = 전혀 다운로드가 없습니다 .

Forget validator, bandwith and speed because this is the major benefit. Otherwise, any other CDN option will perform essentially at the same level.


Is one potentially faster than the other?

I was actually curious of this myself so I setup a jsbin test page using each of the following and then ran it through webpagetest.org's visual comparison tool. I tested:

  1. ajax.googleapis.com
  2. code.jquery.com
  3. ajax.aspnetcdn.com
  4. cdnjs.cloudflare.com

Who was fastest: code.jquery.com by 0.1 second in both tests

Who was slowest: ajax.aspnetcdn.com by 0.7 seconds in first test and ajax.googleapis.com by 1 second in second test

Here's the 1st test (each was tested 3 times):

Video: http://www.webpagetest.org/video/view.php?id=121019_16c5e25eff2937f63cc1714ed1eac814794e62b3

Reports: http://www.webpagetest.org/video/compare.php?tests=121019_D2_KF0,121019_9Q_KF1,121019_WW_KF2,121019_9K_KF3

Here's the 2nd test (another 3 each):

Video: http://www.webpagetest.org/video/view.php?id=121019_a7b351f706cad2c25664fee7ef349371f17c4e74

Reports: http://www.webpagetest.org/video/compare.php?tests=121019_MP_KJN,121019_S6_KJP,121019_V9_KJQ,121019_VY_KJR


As stated by Pingdom:

When someone visits your site, if they have already visited another site that uses the same jQuery file on the same CDN, the file will have been cached and doesn’t need to be downloaded at all. It can’t get any faster than that.

This means that the most widely used CDN will have the odds on its side, which can pay off for your site.

A few observations on performance: Google’s CDN is consistently the slowest of the three both in North America and Europe. In Europe, Microsoft’s CDN is the fastest.


I think it depends on where is your targeted audience. You can use alertra.com to check both CDN speed from many locations around the world.


One additional consideration - if your site is SSL and you need to support Android 2.1 (or earlier), the SSL certificate on the HTTPS version of the Microsoft CDN will crash those versions of the Android browser, per this issue: http://code.google.com/p/android/issues/detail?id=5001. It's not Microsoft's "fault", as the SSL certificate is technically valid and the defect is in Android's SSL implementation... but it will crash your site, nonetheless.

The SSL cert on Google's CDN does not fall afoul of this particular issue (relating to the certificate's "Certificate Subject Alt Name").

So, for SSL + Android 2.1 support, use the Google CDN.


My answer is bit different than others, I will go with microsoft if you need jquery validator which almost everyone need if you are using jquery.

Microsoft CDN http connection is Keep-Alive which is big plus when you are requesting multiple items.

So if you need jquery validation then use Microsoft CDN, even if you need jquery ui use microsoft because google not not keeping keep-alive so every request are on it's own. so mixing in that way is plus. if you are using microsoft only for validator then you are doing seperate connection with google server for each request.


In the summery it says that microsoft is not offering UI, that is not correct (any more). It can be downloadloade at http://www.asp.net/ajaxlibrary/cdn.ashx.


Also consider when using Google CDN that some times people make typos such as ajax.googelapis.com. This could potentially create a really nasty xss (cross site scripting) attack. I have actually tested this out by registering a googlapis.com typo and very quickly found myself serving requests for javascript, maps, css etc.

I emailed Google and asked them to register similar CDN typo URL's but have not heard back. This could be a real reason not to rely on CDN's because there are potentially dangerous attackers awaiting the typo requests and can easily serve back jquery etc with an xss payload.

Thank you


Depending which industry the application targets, you may not want to use a CDN managed by other organisations. It often raises issues regarding to compliance, privacy and confidentiality.

For example, when you include Google Analytics in a secure application, the browser still sends the current URL as the "referer" header. Any identifiers, say a session id or secret token may appear in their logs. For example, if a client IP of 192.0.2.5references https://healthsystem.example/condition/impotence, then well, you can infer information which is considered to be rather private.

Other cases include information of consequence, such as an account number, social security number or session information in the URL. That sort of data should never be in the URL as it can be used outside of the application.

While you may trust Google, Microsoft or Yahoo, your users may not.

For industries like Finance, Legal and Health Care, you may want to establish your own CDN with the help of a vendor (e.g. Akamai) with which you can sign a BAA.


I would advise that you base your usage on the general location of the users you're targeting.

If your site is targeted for general public, then using Google's CDN would be a good choice.

If your site is also targeted at China, then using Microsoft's CDN would be a better choice. I know from my experience, as Google's servers kept getting blocked by the Chinese government, rendering websites that uses them un-loadable.

*Note that you can of cos create region specific sites, e.g. cn.mysite.com to cater specifically for China, but if you're low on resources and time, its worth a consideration.

Full list of Microsoft CDN here. http://www.asp.net/ajaxlibrary/cdn.ashx

They have since renamed to ajax.aspnetcdn.com, which reduces the likelihood of blockage by firewall rules.


I would use both!

As the Google Jquery hosting has been around a lot longer, the chances are much higher that people will already have it cached compared to the Microsoft one, so I would have it first.

Personally, I would use something like this -

if (typeof jQuery == 'undefined') {  
    // jQuery is not loaded  

  document.write("<scr" + "ipt type=\"text/javascript\" src=\"http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js\"></scr" + "ipt>");
        }
} else {
    // jQuery is loaded
}

(Not sure this 100% works, but I was just going to write the idea and not example - This references the Google hosted Jquery and not the Microsoft one as I couldn't find the link)

참고URL : https://stackoverflow.com/questions/1447184/microsoft-cdn-for-jquery-or-google-cdn

반응형