ASP.NET捆绑 - 捆绑不更新后包含的文件发生了改变(返回304不修改) [英] ASP.NET Bundling - Bundle not updating after included file has changed (returns 304 not modified)
问题描述
我尝试了ASP.NET捆绑在ASP.NET MVC应用4。这种情况是我想要做一个CDN式的服务,其中有JS和CSS文件,你可以从其他网站使用这种类型的地址地址:的http://www.mycdn.com/scripts/plugin/js ,该捆绑和minifies包括所有.js文件。
I am trying out ASP.NET Bundling with ASP.NET MVC 4 application. The situation is that I want to make a CDN style service, which has JS and CSS files to which you can address from other sites with this type address: http://www.mycdn.com/scripts/plugin/js, which bundles and minifies all included .js files.
我对一个文件包的配置是这样的:
My bundle config for one file looks like this:
bundles.Add(new ScriptBundle("~/Scripts/plugin/pluginjs").Include("~/Scripts/plugin/jquery.plugin.js"));
不过,我这样做的时候,束没有得到即使我改变原来的js文件更新。我不断收到304未修改,当我刷新我的浏览器,并缩小的文件的内容不会被更新。我怎样才能挣大钱的更新,因为它是没用的,有旧的内容包?我尝试了一切办法,但不能想出一个解决方案。
However, when I do this, the bundles are not getting updated even after I change the original js files. I keep on getting 304 Not Modified, when I refresh my browser, and the content of the minified file is not updated. How can I make bundles update, because it is useless to have bundles with old content? I tried out every way, but could not figure out a solution.
在此先感谢!
推荐答案
我只是有完全相同的问题。我有一个文件夹2 CSS文件:
I just had the exact same problem. I have a folder with 2 CSS files:
- 〜/内容/的main.css
- 〜/内容/ main.min.css($ P $从我的previous手动缩小过程对现有的)
我的捆绑code是这样的:
My bundling code is this:
bundles.Add(new StyleBundle("~/css/main").Include("~/content/main.css"));
不管我多么改变了我的的main.css
输出是相同的URL具有相同的内容:
No matter how much I changed my main.css
the output was the same url with the same contents:
<link href="/css/main?v=6Xf_QaUMSlzHbXralZP7Msq1EiLTd7g1vId6Vcy8NJM1" rel="stylesheet"/>
更新包的唯一方法是重建我的解决办法 - 显然不是最好的方法。
The only way to update the bundle was to rebuild my solution - obviously not the best approach.
然而只要我删除 main.min.css
,一切都开始工作了就好了。更多的上场一点我发现,如果有两个的main.css
和 main.min.css
,然后更新 main.min的.css
,实际上会更新包......怪诞,但至少predictable。
However as soon as I deleted main.min.css
, everything started to work just fine. Playing a little more I discovered that if there are both main.css
and main.min.css
, then updating main.min.css
will actually update the bundle... Weirdness, but at least predictable.
希望这有助于。
这篇关于ASP.NET捆绑 - 捆绑不更新后包含的文件发生了改变(返回304不修改)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!