简体   繁体   English

了解CDN

[英]Understanding CDN's

I've been downloading jquery with: 我一直在用以下方法下载jquery:

<script src="//code.jquery.com/jquery-1.10.2.js"></script>

and for some reason, the link went bad. 由于某种原因,链接变坏了。 Not a problem as I changed the link to use Microsoft's hosted CDN. 没问题,因为我将链接更改为使用Microsoft的托管CDN。 I'm wondering though if I should just download the files so to prevent this problem happening again in the future. 我想知道是否应该只下载文件,以防止将来再次发生此问题。 Is there any reason not to? 有没有理由吗?

Ultimately if you download the files to your own server then you will not experience the same issue again. 最终,如果将文件下载到自己的服务器,则不会再遇到相同的问题。 But there are other considerations: 但是还有其他注意事项:

Plus points for CDNs CDN的加分

  1. may be faster network and worldwide mirrors so potentially better user experience / performance for your site users; 可能是更快的网络和全球镜像,因此可能为您的站点用户带来更好的用户体验/性能;
  2. if you link to the latest version, eg library-latest-min.js then you do not have to alter your source code to get latest bug-fixed version of library (see negative below). 如果您链接到最新版本,例如library-latest-min.js,则不必更改源代码即可获取库的最新错误修复版本(请参见下面的否定)。

Negative points 负点

  1. If the CDN goes offline your site breaks. 如果CDN脱机,则您的站点将中断。
  2. If the CDN has a network slowdown your users suffer. 如果CDN的网络速度变慢,您的用户将受苦。
  3. If you link to the latest version, eg library-latest-min.js then you do not have to alter your source code to get latest big-fixed version of library but if 'latest' holds any breaking changes then your site breaks. 如果您链接到最新版本,例如library-latest-min.js,则无需更改源代码即可获得最新的big-fixed库的最新版本,但是如果'latest'拥有任何重大更改,则您的网站将崩溃。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM