cdn的清理cdn缓存
CDNs are great for pulling shared resources from, especially JavaScript libraries. The advantage in the likelihood that a file is already cached before the user gets to our site is huge. The only problem with using a CDN is that it's out of control; more specifically, what if the CDN server is down? What a nightmare! Thousands if not millions of websites would be hurt...but not yours. Nope, you added a CDN fallback so that a failed CDN wouldn't hurt your site!
CDN非常适合从中获取共享资源,尤其是JavaScript库。 在用户到达我们的网站之前已经缓存了文件的优势是巨大的。 使用CDN的唯一问题是,它不受控制。 更具体地说,如果CDN服务器已关闭怎么办? 什么样的恶梦! 数以千计甚至数百万个网站可能会受到伤害……但您的网站却没有受到伤害。 不会,您添加了CDN后备功能,以便CDN失败不会损害您的网站!
HTML / JavaScript (The HTML / JavaScript)
The document.write method is one you generally want to avoid, but it works best in this case:
通常您希望避免使用document.write方法,但是在这种情况下,它最有效:
<!-- Use Google CDN for MooTools, local Moo as a callback -->
<script src="//ajax.googleapis.com/ajax/libs/mootools/1.4.1/mootools-yui-compressed.js"></script>
<script>!window.MooTools && document.write(unescape('%3Cscript src="/js/mootools-yui-compressed.js"%3E%3C/script%3E'))</script>
In the event that the CDN fails, your local file is instead used. Simple but clever fallback, yes? The likelihood that Google or other CDNs is down is small, but since you don't control the other server, there's always that risk! Play it safe!
如果CDN失败,则改用您的本地文件。 简单但明智的后备,是吗? Google或其他CDN宕机的可能性很小,但是由于您不控制其他服务器,因此总会有这种风险! 安全播放!
cdn的清理cdn缓存