Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting the latest version from cdnjs [closed]

Tags:

javascript

cdn

I would like to pull the latest version from my Content Delivery Network.

Q: Instead of saying:

cdnjs.cloudflare.com/ajax/libs/modernizr/2.6.2/modernizr.js

Is there way to say something like:

cdnjs.cloudflare.com/ajax/libs/modernizr/modernizr.js

And NOT include the version number?

like image 735
Phillip Senn Avatar asked Feb 10 '13 18:02

Phillip Senn


People also ask

What is Cdnjs Cloudfare com?

cdnjs.cloudflare.com is an ultra-fast, reliable, globally available content delivery network for open-source libraries. Cloudflare works with the maintainers of the cdnjs project and distributes the latest versions as they are released.

Is CDN open source?

cdnjs. cdnjs is another free CDN (open source) that host a lot of different libraries, not just the most popular ones, including JavaScript, CSS, SWF, images, etc. It is currently sponsored by KeyCDN, Cloudflare, UserApp, and Algolia.


1 Answers

You don't want to do this. CDN is all about aggressive caching. E.g. CDN servers are sending far in the future Expires headers to make sure the resource remains cached.

If there was a URL always pointing to the most recent version, all your caching goes crazy. Some clients still see the old version while others get the new one. In fact adding a version or other tag is a known technique to make sure new versions are fetched and no caching is involved on the client side. Just look at the source code of the page you are looking at:

http://cdn.sstatic.net/js/stub.js?v=655f0a867d03

Without the noise in v parameter StackOverflow team could never have both: fantastic caching and ability to push new versions quickly and reliably.

Last but not least - are you sure you want to blindly load newest script version with unknown bugs and deprecations? Taking the first part into consideration, even if someone is complaining, it's hard to tell which version is he really using.

like image 81
Tomasz Nurkiewicz Avatar answered Sep 17 '22 18:09

Tomasz Nurkiewicz