开发者

Method for managing version control of static resources: javascript/css/html files etc

I'm working on a RIA system which has a huge number of static resources.

The legacy system renames static files (with a version number) during the build process and has a process which runs through all the pages (which are stored in a legacy database) and updates the filenames in the links.

Now we're running alongside this an Asp.Net MVC application. The situation is made more complex by the fact that the 2 systems share static resources.

I'm contemplating putting the version number into the web.config, and 开发者_如何学Cthen adding a modified version of the code from this article: http://www.codeproject.com/KB/aspnet/autojscssversion.aspx, - then let the legacy process manage the numbering on ALL of the static resources for both systems.

Has anyone come across any better methods for managing this kind of thing?

I'm a little surprised though that it's all this clunky - are there any better approaches?


A common approach for ensuring browsers download the latest versions of your static files is to tack on a query string to the URL.

For example, your application would request something like /scripts/common.js?version=4.

This would probably reduce the complexity of your build process, because you wouldn't need to rename any files during the build. Then, you could simply put the build/version number in a config file, and change all the URLs to add the version query string at runtime.


I can't say enough good about switching static resource calls into an included file. It sounds so terribly easy, but since I went this route I have cut my maintenance overhead to nearly nothing. One change fixes every page. Yes, there's a bit more overhead loading files that may not get used on certain pages, but in the grand scheme of things it's small and offset by caching.

From a scheme standpoint, I have a naming convention that prefixes files with the codebase (jquery, themeroller, etc) followed by a dot, plus the name of the script, follwed by a dot and js.

Also, make great use of CDN hosted code where possible. Google and Microsoft host several projects via CDN that are going to load faster to the user than most people's servers do. It also distributes HTTP connections between servers, which in theory should also offer a slight performance increase. Google has some unique strategies for dealing with versioning on CDN hosted files which also could come in very handy. The one drawback is that CDN hosted code is only available for major projects like JQuery, etc, which doesn't help you when you have use one of the many other quality scripts out there.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜