0

The clients have a caching problem with most of our resources when we change them because the client's cache is not invalidated at every release.

Possible solution 1: Being from .net MVC, I was thinking about making an helper that handle every resources and assign them a version, example:

@SomeHelper.VersionJsFile("~/scripts/somejs1","~/scripts/somejs2","~/scripts/somejs3")

Would output:

<script src="~/scripts/somejs1?v=1234">
<script src="~/scripts/somejs2?v=1234">
...

The problem: I dont know how to do such similar thing in ASP .net. The problem2: Lots of file and may forget some of them.

Possible solution 2: The other solution would be to go trough all the files (a lot of files... Actually, a sh*tload of files) and enter the version manually:

<script src="scripts/somejs1.js?v=<%=version %>

The problem: Lots of file and may forget some of them.

Possible solution 3: Writing a custom filter stream as described in this example: Filter stream example

The problem: Dangerous, if the filter crashes, the client may not be able to use the software at all. The problem2: Quite "hard" to properly implement since I'm not used to work with streams. The problem3: Quite "hard" to maintain for future devs.

Possible solution 4: Use YUIcompression tool. Don't think about it. This is legacy code and it is too late for that.

My question: What is the best way to version file in such system? If I already found the good solution, do you have tips on how to properly implement the said solution?

Nicholas Murray
  • 13,305
  • 14
  • 65
  • 84
Jean-Philippe Leclerc
  • 6,713
  • 5
  • 43
  • 66

1 Answers1

3

I've had a lot of luck using Cassette for both bundling and versioning of js resources. It supports webforms, and be used for versioning/cache busting only in the options. It would take a bit of setup of your resources in the configuration, but you would only need to configure it in once place and the pages can just reference their resources when they need it.

tsandhol
  • 501
  • 4
  • 4