https://www.davepaquette.com/archive/2015/05/06/link-and-script-tag-helpers-in-mvc6.aspx

It is a common approach to reference popular frameworks from hosted CDN in order to reduce network load on your server and potentially improve performance for the end user. For popular frameworks like jQuery and Bootstrap, there is a good chance that the browser will already have a cached version of these files.

Referencing files from a CDN can be a bit of a pain because you also need to provide a fallback to a version of the file hosted on your servers. A fallback is necessary because you do not want your application to go down just because the CDN is not currently reachable.

The script and link tag helpers make it easier to specify a fallback test and file location. Here is a basic example for the popular Bootstrap framework:

<link rel="stylesheet" href="//ajax.aspnetcdn.com/ajax/bootstrap/3.0.0/css/bootstrap.min.css"
asp-fallback-href="~/lib/bootstrap/css/bootstrap.min.css"
asp-fallback-test-class="hidden"
asp-fallback-test-property="visibility"
asp-fallback-test-value="hidden" /> <script src="//ajax.aspnetcdn.com/ajax/bootstrap/3.0.0/bootstrap.min.js"
asp-fallback-src="~/lib/bootstrap/js/bootstrap.min.js"
asp-fallback-test="window.jQuery">
</script>

cdn and fallback的更多相关文章

  1. CoreCRM 开发实录——开始之新项目的技术选择

    2016年11月,接受了一个工作,是对"悟空CRM"进行一些修补.这是一个不错的 CRM,开源,并提供一个 SaaS 的服务.正好微软的 .NET Core 和 ASP.NET C ...

  2. jquery cdn bootstrap静态资源库问题

    使用微软静态资源库 <script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.9.0.min.js">&l ...

  3. asp.net mvc自动压缩文件,并生成CDN引用

    很多站点都是用了静态文件分离.我推荐一种处理静态文件分离的方式. BundleExtensions.cs public static class BundleExtensions { public s ...

  4. 配置vue项目将打包后图片文件的引用路径改为cdn路径?

    vue cli3项目, 需求: 图片文件打包时, 将项目内的所有图片文件的引用地址改为cdn路径 vue cli3的默认配置下, 打包后图片使用的是相对路径, 例如打包后项目内图片引用路径为 img/ ...

  5. Kendo UI使用教程:CDN服务

    [Kendo UI最新试用版下载] Kendo UI目前最新提供Kendo UI for jQuery.Kendo UI for Angular.Kendo UI Support for React和 ...

  6. 百度MIP移动页面加速——不只是CDN

    MIP是用CDN做加速的么?准确答案是:是,但不只是. MIP全称Mobile Instant Pages,移动网页加速器,是百度提出的页面加速解决方案.MIP从前端渲染和页面网络传输两方面进行优化, ...

  7. 【初码干货】使用阿里云对Web开发中的资源文件进行CDN加速的深入研究和实践

    提示:阅读本文需提前了解的相关知识 1.阿里云(https://www.aliyun.com) 2.阿里云CDN(https://www.aliyun.com/product/cdn) 3.阿里云OS ...

  8. 阿里云系列——6.给你的域名使用CDN加速(详细步骤+简单配置)

    网站部署之~阿里云系列汇总 http://www.cnblogs.com/dunitian/p/4958462.html 进入管理页面:https://home.console.aliyun.com/ ...

  9. Signalr系列之虚拟目录详解与应用中的CDN加速实战

    目录 对SignalR不了解的人可以直接移步下面的目录 SignalR系列目录 前言 前段时间一直有人问我 在用SignalR 2.0开发客服系统[系列1:实现群发通讯]这篇文章中的"/Si ...

随机推荐

  1. OSCP-Kioptrix2014-1 环境搭建

    环境搭建 该系列文章参考 : https://www.youtube.com/watch?v=bWM0BCQ5q1o&list=PL9WW-prbqvGzHsGK_OqTyYWbCZjucpI ...

  2. ubuntu系统新用户添加

    大概是4个步骤吧,是用脚本实现的,这里我列一下关键点 sudo useradd -m userYouWantAdd sudo passwd userYouWantAdd sudo usermod -a ...

  3. SpringBoot整合MongoDB JPA,测试MongoRepository与MongoTemplate用法,简单增删改查+高级聚合

    源码 地址 -> https://github.com/TaoPanfeng/case/tree/master/04-mongo/springboot-mongo 一 引入依赖 <depe ...

  4. 实现代码重启android app.

    var Form1: TForm1; implementation uses System.DateUtils, Androidapi.JNI.GraphicsContentViewText, FMX ...

  5. ORM简单增删改查

    namespace ORM { class Program { static void Main(string[] args) { //AddPetStore();//添加 UpdatePetStor ...

  6. Delphi 配置BDE数据源

    樊伟胜

  7. linux 进程优先级 调度 nice pri

    转:http://www.linuxidc.com/Linux/2016-05/131244.htm 深入 Linux 的进程优先级 [日期:2016-05-11] 来源:liwei.life  作者 ...

  8. C# 列表中查找大小比较

    列表中查找大小比较

  9. mysql数据库:mysql增删改、单表、多表及子查询

    一.数据增删改 二.单表查询 三.正表达式匹配 四.多表查询 五.子查询       一..数据增删改     增加  insert [into] 表名[(可选字段名)] values(一堆值1),( ...

  10. Spring mvc 初始化过程

    1.DispatcherServlet:获取servlet的name 2.XmlWebApplicationContext:获取contentConfigLocation的xml名称和namespac ...