2

I'm generating stylesheet/javascript links all over my website using a single extension method, so i have a place to generate querystring.

Example

http://mydomain.com/site.css?v0.0.1

The plan is when i do a new build, the content should be fetched freshly from the server. No surprises there.

However, i'm trying to figure out the best way to generate this value.

Obviously, ideally, doing something as a MSBuild task is the most ideal, but i've tried and failed that in the past.

We're using SquishIt for most static content, but for files not in the bundle (e.g ones that aren't required on every page), we need to generate the querystring param for the file.

I'm thinking i create a singleton guid on app start, then use that when generating links.

Thoughts?

RPM1984
  • 72,246
  • 58
  • 225
  • 350
  • 1
    Wouldn't be better to use version or date from assembly? http://stackoverflow.com/questions/324245/asp-net-show-application-build-date-info-at-the-bottom-of-the-screen – Giedrius Sep 27 '11 at 07:04

2 Answers2

0

I learned about Knapsack from Steven Sanderson's blog post about Open-source components used in learn.knockoutjs.com. I'm not quite sure, but maybe you should take a look at its quick walk-through

archil
  • 39,013
  • 7
  • 65
  • 82
  • But that's for bundling js/css, if im not mistaken. We're already using SquishIt for that. I'm talking about the instances where you *dont* want the file in the bundle, but still want it cached for the current build. Unless im missing something? – RPM1984 Sep 27 '11 at 09:31
0

I prefer reading the assembly or application version once (either in app_start or do lazy loading in helper method) and use that for building url to my js/css. We change the version number for all releases (internal or external) so works like a charm.

VinayC
  • 47,395
  • 5
  • 59
  • 72
  • So if you read that in once, where/how do you store it? Is it a (static) instance in some global class? – RPM1984 Sep 27 '11 at 09:29
  • @RPM1984, yes - its private static variable in the static utility class containing method forming the url. – VinayC Sep 27 '11 at 10:53