Reputation: 2124
I need to increase the javascript file versions in my project automatically, that my users always have the correct javascript code in their browsers and not the cache.
Each time I release a new version of my project, I need to change every .js file, that is included in a .aspx file.
For example:
SampleFile.aspx:
<script type="text/javascript" src="file1.js" />
<script type="text/javascript" src="file2.js" />
<script type="text/javascript" src="file3.js" />
Starting a tool change ingreases the version:
<script type="text/javascript" src="file1.js?v1" />
<script type="text/javascript" src="file2.js?v1" />
<script type="text/javascript" src="file3.js?v1" />
Next version:
<script type="text/javascript" src="file1.js?v2" />
<script type="text/javascript" src="file2.js?v2" />
<script type="text/javascript" src="file3.js?v2" />
and so on...
I have many files, so it is frustrating to change every file each time.
Upvotes: 0
Views: 150
Reputation: 207511
Most people run a build script when they release their project to QA/Production. The build script can handle adding the version numbers and do the file compressions. Look into NAnt
Upvotes: 0
Reputation: 129792
Rather than incrementing an integer, let your version flag be a hash of the content of the file. This way, your cache invalidation will be entirely automatic. Also, you would want to combine those files. Combres handles both these issues for you (as well as minifying and GZipping).
Upvotes: 2