What files fit to load with CDN
CDN is mainly used for loading some static resource files, such as JavaScript files, CSS style files, fonts, pictures, videos and other resource files. These files tend to be handled in some of our front-end servers (Nginx), and a CDN can be used to exempt the front-end server parts from the work.
Benefits of using CDN
Improve the performance of your Web site
The biggest benefit of using CDN is to provide "shunt" for your server, save your bandwidth, reduce the pressure of the server, many CDN vendors provide the resource access service faster than the loading speed (except the wall).
File caching
For those commonly used resource files (such as jquery), if the user has visited your site before access to other sites using the CDN, then in the user's browser has been cached in this resource file, for your site, this is a good performance improvement!
Highly Available
Believe that Microsoft, Google, Yahoo's servers are more reliable than your own servers, they provide high availability, low network latency, and reduce the risk of packet loss. You don't have to worry about server downtime or network latency.
Resource file Version Management
For some resource file upgrades (Css,js Lib), you don't need to load the latest version every time you modify the program, just specify that the "lastest" file is always loaded when you load the CDN resource file.
CDN Use Tips
Omit the protocol for the URL, and remove http: or https: This eliminates the protocol's suitability issues. Such as:
<script type= "Text/javascript" src= "//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js" ></ Script>
Just in case, provide an alternate local resource file.
The recent Google Wall is very bad, resulting in a lot of use of WordPress site, loading speed is very slow, or even directly caused the page can not be loaded, for security reasons, we provide a local backup resource file:
<script type= "Text/javascript" src= "Http://ajax.microsoft.com/ajax/jquery/jquery-1.4.2.min.js" ></script >
<script type= "Text/javascript" >
if (typeof jQuery = = ' undefined ') {document.write (unescape) (
" %3cscript src= '/js/jquery-1.4.2.min.js ' type= ' text/javascript '%3e%3c/script%3e ')
}
</script>
Some of the most common CDN
Google:https://developers.google.com/speed/libraries/devguide
Microsoft:http://www.asp.net/ajaxlibrary/cdn.ashx
jquery:http://jquery.com/download/
Cdnjs:http://cdnjs.com
Osscdn:http://osscdn.com