1

I'm maintaining an asp.net 3.5 website deployed on IIS 6.0 and I have made some fixes to a javascript file "scormapi.js" and should copy it (just this file) to the client website server. My problem is that the script reference to to this file with its version is injected into the page through server side code:

ClientScript.RegisterClientScriptInclude("DWScormAPI.js", ResolveUrl("~/Scripts/scormapi.js?Version=3.3"))

Which means that the client browser will use the cached file if I just do a copy of the file. Is there anyway to force the browser to use the new copied version of the file without recompiling and deploying the dll.

Thanks

EDIT:

I thought of adding to the aspx pages that uses the js file a tag that reference this js file with a different version number, or maybe using jquery $.getScript(). But in this case I would have two script references to the same file on the same page and I wonder if there is anyway to tell the page use this version of the file instead of that version.

NB: This is not duplicate question. I'm asking whether there is an alternative solution that avoids me modifying my server side code and then do a recompile and full deployment. The duplicate question some folks are referring to is just not what I'm asking about.

khaled
  • 132
  • 1
  • 11

2 Answers2

3

The only way to 'force' a browser to fetch a file instead of used its cached version is to change the URL in some way. In our system, our 'url injection' includes a query string with a timestamp - looks like "...something.js/140324" for a file that changed yesterday.

n8wrl
  • 19,439
  • 4
  • 63
  • 103
0

Here are some ideas for updating the js file for your users.

You could have the ?Version= have a value that changes every X minutes which forces the client to load a fresh js file every X minutes when visiting the website.

If you really must detect it server-side you could let the ?Version= have the value matching the last edit info for that file. E.g. let the server find the file on the system and examine last edit info and append that info to the ?Version= url part.

Kunukn
  • 2,136
  • 16
  • 16