My MVC4 application is using Scripts.Render
to load a bundle that is loading a file called "functions.js."
When I debug this application in the browser, the script loads, but the version is outdated. When I view the resource directly, but append ?v=anytext
the script looks correct, but without that appended, the script shows the old code. Is there a way to force the bundling to output the correct file instead of a stale one?
This is likely a caching issue. When using Bundling and Minification in debug mode (when
<compilation debug="true" />
is set in yourweb.config
), bundling/minification is disabled.You can override this and force bundling and minification by adding
BundleTable.EnableOptimizations = true;
. This will make it act like it will in your production environment, where everything is bundled and minified, and the script reference includes that versioning parameter (like you gave) that will force the browser to reload your scripts when anything changes.