Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9193779
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:14:45+00:00 2026-06-17T21:14:45+00:00

Possible Duplicate: How do I force the refresh of javascript files in a browser?

  • 0

Possible Duplicate:
How do I force the refresh of javascript files in a browser?

My application in ASP.NET MVC based and javascript files are included in .csHtml file.

I require this so that the user do not have to do a [Ctrl+F5] or manually clear cache and the most recent version of javascript file is loaded everytime in the browser.

I appreciate if some examples can be provided.

Primary technique suggested is to use a dummy paramater while including the file.
Also I do not what to change the parameter manually every time I modify a js file. Need some examples if this can be done automatically.

EDIT 1:
Please provide solution to this with ASP.NET MVC prospective.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T21:14:47+00:00Added an answer on June 17, 2026 at 9:14 pm

    You want to use Bundling and Minification. Depending on your version of MVC, the implementation is slightly different. In the newest version, it is used by default.

    Bundling and Minification will combine and minify all your scripts (and styles sheets) into one file (or multiple, depending on how you use it) and serve them up with a unique parameter. Any time a file changes in that particular bundle (and thus the user would require to download the new files) the parameter automatically changes.

    For MVC3, you’ll need to install Microsoft Web Optimization.

    Then in your global.ascx, you’d do something like this and call it from Application_Start:

    private static void SetupBundling()
    {
         var jsBundle = new Bundle("~/Scripts/js", typeof(JsMinify));
         jsBundle.AddDirectory("~/Scripts/", "*.js", false);
         jsBundle.AddDirectory("~/Scripts/anothr-good-folder/", "*.js", false);
         BundleTable.Bundles.Add(jsBundle);
    
         var randomBundle = new Bundle("~/Scripts/random", typeof(JsMinify));
         randomBundle.AddFile("~/Scripts/random/main.js");
         randomBundle.AddFile("~/Scripts/random/cool.js");
         BundleTable.Bundles.Add(randomBundle);
    
         var cssBundle = new Bundle("~/Content/css", typeof(CssMinify));
         cssBundle.AddDirectory("~/Content/", "*.css", false);
         BundleTable.Bundles.Add(cssBundle);
    }
    

    So that first bundle will bundle every .js file in your ~/Scripts folder. In your head file you can reference it like:

    <script src="@Microsoft.Web.Optimization.BundleTable.Bundles.ResolveBundleUrl("~/Scripts/js")" type="text/javascript"></script>
    

    And it will be rendered like:

    <script src="/Scripts/js?v=-2573834892993289" type="text/javascript"></script>
    

    And any time one of your .js files change (or .css), so will the parameter.

    Similar implementation for the CSS bundle, and also if you want to reference the randomBundle only on certain pages.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Javascript force open a link in a browser I am working on
Possible Duplicate: How to catch exceptions in javascript? I am changing old web application.
Possible Duplicate: How to force using zxing lib with only my application? I use
Possible Duplicate: Force refresh of cached data Whats the best practice for updating the
Possible Duplicate: Force Download an Image Using Javascript Basically I want to have the
Possible Duplicate: How to force my .NET App to run as administrator on Windows
Possible Duplicate: Mobile site - force landscape only / no auto-rotate I have seen
Possible Duplicate: && operator in Javascript In the sample code of the ExtJS web
Possible Duplicate: Force app to close and run in background I'm creating an radio
Possible Duplicate: How to get file descriptor of buffer in memory? I'm trying to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.