我使用单个扩展方法在我的网站上生成样式表/javascript 链接,因此我有一个地方可以生成查询字符串。
示例
http://mydomain.com/site.css?v0.0.1
该计划是当我进行新构建时,应该从服务器新鲜获取内容。那里没有什么惊喜。
但是,我正在尝试找出生成此值的最佳方法。
显然,理想情况下,作为 MSBuild 任务执行某些操作是最理想的,但我过去曾尝试过但失败了。
对于大多数静态内容,我们使用 SquishIt ,但对于不在捆绑包中的文件(例如并非每个页面都需要的文件),我们需要为该文件生成查询字符串参数。
我想我在应用程序启动时创建一个单例指南,然后在生成链接时使用它。
想法?
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?
发布评论
评论(2)
我更喜欢读取一次程序集或应用程序版本(在 app_start 中或在辅助方法中进行延迟加载)并使用它来构建我的 js/css 的 url。我们更改了所有版本(内部或外部)的版本号,因此效果非常好。
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.
我从 Steven Sanderson 的有关 Knapsack /2011/07/22/review-open-source-components-used-in-learnknockoutjs/" rel="nofollow">用于的开源组件learn.knockoutjs.com。 我不太确定,但是也许您应该看一下它的快速演练
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