I've faced recently an issue that I've solved in a very simple but not very scalable way, and I'd like to know which approach do you take for it.

The situation is common to all non-trivial web projects, but in this case I'd like a solution that fits also the particularities of Sharepoint and ASP.NET's projects in Visual Studio 2010:

We have, for instance, one file named "Global.js" containing all-purpose JS functions that need to be called from:

  • .aspx code of a Webpart, included in a Sharepoint's page.

  • Elements.xml file, specifying code to be called when a CustomAction is triggered (new Button inside Sharepoint's Ribbon).

The problem here is:

  1. User enters our webpage.
  2. User's browser caches Global.js file.
  3. We deploy a new functionality including a new version of Global.js file.
  4. User enters our webpage. Functionality fails because the browser has the old Global.js in its cache.
  5. User(Client) calls/emails us!

As a solution, I've decided to start using versioning of js files, so the browser knows when its cached version is old and needs to reload it.

The simpliest way I've found is to include at the end of each link, a querystring indicator with a param of the version. For instance: "/Global.js?v=1.0" . Now, when I'm deploying a new package that includes changes on js file, I just need to change the "v" parameter value.

However, this solution scalates poorly, because you need to find&replace the link among all the files of the project.

So, I'd like to insert a sort of constant or token that indicates the version of the file in only one place and can be referenced from any place of the code. The main issue here is that, although it's easy to implement it when inserting the link in an aspx page, including links in files like "Elements.xml" is very restricted that you can't use Server-Side or JS code easily.

What do you suggest to implement centralized versioning for files linked from anywhere in the project?

Related posts

Recent Viewed