开发者

Generating QueryString Param For Static Content Once Per Application

开发者 https://www.devze.com 2023-04-07 15:31 出处:网络
I\'m generating stylesheet/javascript links all over my website using a single extension method, so i have a place to generate querystring.

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 开发者_JAVA百科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?


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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号