1

I've read thru answers to this question: ASP.NET Bundling - Bundle not updating after included file has changed (returns 304 not modified)

However, none of the answers fix or match with what I am seeing.

First, I am able to reproduce my issue on Windows 10 and Windows 2012 server.

I have built my project in release mode, changed debug=false in web.config.

I have updated my project to the Microsoft.AspNet.Web.Optimization NuGet package, version 1.1.3

My bundle setup looks like this:

public static void RegisterBundles(BundleCollection bundles)
{
   BundleTable.EnableOptimizations = true;
   bundles.Add(new ScriptBundle("~/bundles/mybundle")
      .Include("~/Views/User/UserSearch.js")
      .Include("~/Views/User/UserEdit.js")
   );

   ...
}

Neither of the files listed in the bundle (UserSearch.js, UserEdit.js) have .min versions in the directory or anywhere else.

The end of my User.cshtml file looks like this:

@section Scripts {
   @Scripts.Render("~/bundles/otherstuff")
   @Scripts.Render("~/bundles/mybundle")
   <script type="text/javascript" src="AnotherFile.js"></script>
}

All that said, when I view the page, I see a request for the bundle come thru:

https://local/bundles/mybundle?v=wlen6W7mg528CIKzW0x3ewQacQ6mf8wyin1XGaXoonQ1

I then make a change to my UserSearch.js file by adding an alert('hi'); line at the top.

At this point, if I refresh the page, I am expecting the v= querystring parameter to change, and the alert box to appear. But it does not.

If I recycle the site or IIS, and visit the page again, I get the alert box.

Is cache-busting supposed to work on the fly without re-compile or recycling?

Are there any other things that could be interfering with either the bundler not recognizing the file change OR the @Scripts.Render() not writing out a new token?

Community
  • 1
  • 1
slolife
  • 19,520
  • 20
  • 78
  • 121
  • Not a complete answer (because it assumes this does work as you expect, which it apparently doesn't), but more info at https://stackoverflow.com/questions/12317391/how-to-force-bundlecollection-to-flush-cached-script-bundles-in-mvc4/12324888#12324888 – James White Oct 16 '17 at 17:17

0 Answers0