Serve libraries with CDN or Own Server?

Asked

Viewed 191 times

4

Aiming performance is more performative to use a CDN (providing the library’s full and primary version) or distributing versions of Custom Libraries (e.g.: jQuery UI that provides only the effect accordion). It is possible also my site to use the jQuery UI downloaded by another site even though it is different (complete and my cost having only the necessary function)? There is some other crucial factor?

  • For custom libraries, you can use Amazon AWS. It’s almost free. http://aws.amazon.com/pt/

2 answers

5


The main function of a CDN for a developer is not to be concerned about network traffic and to be able to guarantee visitors always availability of files. For the user is to get from a second domain (parallel upload) the files, from a place that would probably be closer physically decreasing the latency (connection time, DNS resolution and download).

If your visitors are geographically close to you, or are unique to a locality (country, country or continent region) there is NOT much need for a CDN, because for users it won’t make so much difference. In this case, I recommend that you create a subdomain or even another domain (ai is your strategy) to serve these files. So you can serve in parallel and from a "cookieless domain".

Ideally, you can get your pages to make as few requests as possible (both for the same domain and several: CDN, subdomains, etc.), so you can increase the page load speed.

Try merging into just a . css or . js (you can develop in separate files, but when it comes to publishing together, or use tools that do this) all the code that will be used by a certain area of your site. Compact (remove unnecessary spaces, indentations, comments, use gzip compression) and cache these files (set the files to be cached by the user for as long as possible, and if you update the data in the files, then change the URL that the user searches for, forcing a new download, updated).

If you are going to provide customization and are using scripting libraries, do not provide a CDN library and its customization to part of your server (or your own CDN). Put it all together in one and make it available to your users. Initially you will increase your server traffic a little, but you will decrease user requests and have control over the caching of these files altogether.

4

Every strategy has its pros and cons...

CDN: The great advantage is that most users who fall on your site will have a version of the library cached. This reduces the time for downloading resources and the bandwidth consumption of your website. Cdns also try to distribute libraries from a server closer to the user, so that if they need to download a library, they do so with less latency.

Custom version: The first time your users access the site (and in later iterations if they no longer have the library cached) they will have to download the library from your server. The latency of a distant user can be high, and this will consume your upload bandwidth. On the other hand, you can select only what you need from each library (which can reduce the download size as well as the processing time / rendering).

It is also possible for my site to use the jQuery UI downloaded by another site even though it is different (complete and my cost having only the necessary function)?

I don’t know if I understood the question correctly, but if you developed your site in a customized version (with only part of the components), you can switch to the most complete version hosted on a CDN without problems. The more popular the CDN, the less chance a user will have to download the library.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.