What is CDN and how to enable it in my JavaScript files?

7

On a performance verification site I received the "Use CDN for all static assets" message for my JavaScript files.

What are CDNs and how to implement them?

    
asked by anonymous 29.11.2016 / 18:42

5 answers

7

Is Content Delivery Network or content delivery network. In fact it is often used more for static content. In general, it is a worldwide network of data centers (points of presence) that makes a "sort of" cache (but not exactly) of content that should be uploaded by your sites giving better performance, not only because they are specialized in this, but also because they are usually closer to those who are requesting the content (through geolocation). In this way, it will unleash your server for "nobler" activities such as generating dynamic content.

In general, it is a very stable and reliable network, and supports high volume of access without losing speed, even in attacks. It can be used as a defense. Even if you totally lose access to the site because your primary servers are experiencing attacks, you may still have a static version of the site being offered. The important thing is that it helps in delivering the content. Obviously it is usually only very useful in cases of sites with reasonable traffic or for standard content that is universally used on most sites. But that's not the focus of this question.

Standard libraries

In some cases it is used by some standard libraries to avoid unnecessary loading of something that that customer has already has locally. If you just want this, just use the address your preferred library uses, as per the linked question above.

jQuery is one of these most used libraries and the address where it indicates where to get it from the CDN is link . Clicking on one of them will appear this:

Thenuse:

<scriptsrc="https://code.jquery.com/jquery-3.1.1.slim.min.js"
    integrity="sha256-/SIrNqv8h6QGKDuNoLGA4iret+kyesCkHGzVUUV0shc="
    crossorigin="anonymous"></script>

Own Content

If you want to make content for your site (image, audiovisual, downloadable files, etc.), you have to hire the service with some specialized company to have an address where to put this content and refer it to your page

The exact way you reference your page depends on each content. But there is no secret, the only difference is that it is not on the same server as the dynamic content, so the file address is another location, it will certainly be an absolute URL giving the whole address (the relative address we normally use only works for local content But it's common HTML, nothing special.

Complement

Some people use CDN for dynamic content, especially live broadcasts and specialized tasks.

The subject is vast, it has a lot of detail, but it would need more specific questions.

    
29.11.2016 / 18:48
2

Content Delivery Network (CDN) is an information distribution network that enables you to deliver Web content faster to a large number of users by distributing content across multiple servers.

Sample CDN:

Jquery

<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>

Angularanimate

<scriptsrc="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.0/angular-animate.js"></script>
    
29.11.2016 / 18:50
2

In the context of web development (and relative to the message regarding static content) CDNs are services where client libraries (usually Javascript and CSS) can be found.

Its focus is on high reliability (uptime, versioning) and performance (baud rate). For this, most of the CDN services have geographically distributed servers, with the aim of reducing the response time.

    
29.11.2016 / 18:57
1

CDN can be viewed with a service that hosts static files from your site and delivers them to the client. This causes the load to be reduced.

For this reason, on the performance verification website you received the message: "Use CDN for all static assets", meaning it is telling you to use a CDN for static files.

The full implementation and a good explanation can be seen at this site . .

    
29.11.2016 / 18:53
0

Content Delivery Network (CDN) is a server that provides content. Usually, to implement it, you insert an external source into the project. Example:

Local

<script src="../caminho/script.js"></script>

CDN

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.js"></script>
    
29.11.2016 / 18:46