Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am using ASP.NET optimization package to minify and bundle the scripts, and CSS files. I am also developing a mobile UI for my ASP.NET application which uses a HTML5 cache manifest.

The optimization package updates the version of the dynamic bundle URL when the files change and the application cache is recycled.

I would like to be able to update my manifest version whenever this happens and include the dynamic URLs the optimization package provides in the manifest.

How can I read the current version (the "v" parameter) or anything else to trigger a manifest update?

/_assets/bundles/global?v=fmbQlO0mGjXyliVEBImQIr5yoMX0Tw0tlMK45jlwHZ81

Example Code:

    string version= "2.6";
    StringBuilder output = new StringBuilder();
    output.AppendLine("CACHE MANIFEST");
    output.AppendLine(string.Format("# v{0}", ??????));


    output.AppendLine("CACHE:");
    output.AppendLine(Scripts.Url("~/bundles/global").ToString());
    ...
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
208 views
Welcome To Ask or Share your Answers For Others

1 Answer

The Application Manifest will automatically trigger an update if it is changed.

With static assets, people usually changed a version number in a comment so that the file was changed and would trigger an update, even though the content under the CACHE, NETWORK and FALLBACK sections were unchanged.

When you are using the URLs generated by System.Web.Optimization, the URL will change when the content of any of the CSS or JavaScript files in the bundles changes. This means that the manifest file will automatically be different to the previous version of the file and will trigger an update.

There is no need to force the file to be different by updating a version comment.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...