Getting the latest version from cdnjs [closed]

 ̄綄美尐妖づ 提交于 2021-02-07 13:36:50

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/14801334/getting-the-latest-version-from-cdnjs

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!