从CDNJS获取最新版本 [英] Getting the latest version from cdnjs

查看:81
本文介绍了从CDNJS获取最新版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从我的内容分发网络中获取最新版本.

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

Q:不用说:

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

是否可以这样说:

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

不包括版本号吗?

推荐答案

您不想这样做.CDN涉及积极的缓存.例如.CDN服务器会在将来发送 Expires 标头,以确保资源仍处于缓存状态.

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.

如果有一个始终指向最新版本的URL,那么您的所有缓存都会发疯.一些客户仍然看到旧版本,而其他客户得到新版本.实际上,添加版本或其他标签是一种确保获取新版本且客户端不涉及缓存的已知技术.只需查看您正在查看的页面的源代码即可:

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

v 参数中没有噪音的情况下,StackOverflow团队永远不会拥有两者:出色的缓存以及快速可靠地推送新版本的能力.

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.

这篇关于从CDNJS获取最新版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆