In the Microsoft MVC4, I see something called bundling
for minifying and caching static resources such as CSS
and JavaScript
. In the ScriptBundle
method I see the first parameter that called virtual path
and it should be relative only.
bundles.Add(new ScriptBundle("~/bundles/jquery").Include("~/Scripts/jquery-1.*"));
For example, ~/bundles/jquery
in above code.
I have one question, how bundling
uses this virtual path
? Is this used for something like file caching?
"The new ScriptBundle object is given a virtual path which can be anything you like. It effectively acts as a name by which the bundle can be identified. It does not have to match an existing path in the web site folder structure."
Taken from http://www.mikesdotnetting.com/article/197/optimising-asp-net-web-pages-sites-bundling-and-minification
@Richard, in case you are still looking for the answer.
Javascript and CSS Minifying/Bundling
Now, the way the JS/CSS minifying works is that it will dynamically inspect all your files, read them, minify them and then cache the result to be served later. This allows us to modify our files and have all the files re-minified. When one of our JS/CSS files get modified again, this process will restart until either the cache expires or a file change.
Also look at this post ScriptBundle and StyleBundle names and includes and link in this post for more details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With