【问题标题】:Customize cache-busting in system.web.optimization在 system.web.optimization 中自定义缓存清除
【发布时间】:2013-02-23 18:58:17
【问题描述】:

在优化时从包中渲染样式时,您会得到:

<link href="/Content/themes/base/css?v=UM624qf1uFt8dYtiIV9PCmYhsyeewBIwY4Ob0i8OdW81" rel="stylesheet" type="text/css" />

不幸的是,Android 浏览器似乎没有load urls with query strings有什么方法可以在 System.Web.Optimization 中自定义这个字符串吗?


编辑:

我的问题得到了解答,我尝试在用户代理字符串上检测 android 并用一个不包含查询字符串的样式表链接替换。显然我遇到的问题不是因为查询字符串,而是 webfont css 的缩小版本导致它无法在 Android 股票浏览器中完全加载样式表。

Android 股票浏览器fails to load css content string with escaped backslash 这是erronously minifies the same css content string 的 ASP.NET 缩小器的解决方法。我最终将图标字体 css 样式放在它自己的“手动缩小”样式表上。

【问题讨论】:

    标签: asp.net-mvc asp.net-optimization system.web.optimization


    【解决方案1】:

    您可以使用

    禁用缓存
    @{string path = BundleTable.Bundles.ResolveBundleUrl("~/bundle/cssCommon", false);}
    //may apply manual path transformation to remove ?v= anyway
    <link href=@path rel="stylesheet" type="text/css" />
    

    或缩写形式

    <link href="@BundleTable.Bundles.ResolveBundleUrl("~/bundle/cssCustom", false)"
    

    但是你会遇到缓存相关的问题,而不是 android WebView 的问题。 另一种可能的方法是使用 Microsoft Ajax Minifier

    【讨论】:

      【解决方案2】:

      不幸的是,我们目前不支持自定义版本字符串在 url 中的显示方式。

      这是我们 codeplex 网站上问题的链接:Url version issue

      与此同时,如果您愿意在每次更改捆绑包时手动修改捆绑包路径,您可以避免使用帮助程序,而只使用指向您每次捆绑包时更新的捆绑包的显式链接变化:

      <link href="/Content/themes/base/css" rel="stylesheet">
      

      或者你可以通过bundle.Cacheability = HttpCacheability.NoCache禁用客户端缓存

      【讨论】:

        猜你喜欢
        • 2015-05-06
        • 2014-09-25
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-10-23
        • 2012-02-05
        • 1970-01-01
        相关资源
        最近更新 更多