Use the advantages of CDN and tips to share _ site operations

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.