Versioning your static resources is one of the options. I personally use a build system as I have far too many files to update manually. Here is a barebone example using gulp
, but you must be able to do the same in your preferred build system/task runner:
// gulpfile.js
var gulp = require( "gulp" ),
... other modules
htmlReplace = require( "gulp-html-replace" ),
replace = require( "gulp-replace" );
gulp.task( "html-resources", function () {
return gulp.src( "./" + config.dir.build + "/**/*" )
// using gulp-html-replace module
.pipe( htmlReplace({
// single instance
"configFile": "config.js?ver=@version@",
// multiple-instances
"bowerComponents": {
"src": config.files.source.bowerComponents, // ["lib1.js",...]
"tpl": "<script src=\"assets/%s?ver=@version@\"></script>"
},
}))
// using gulp-replace module
.pipe( replace( "@version@", version ) )
.pipe( gulp.dest("./" + config.dir.build) );
});
Also one useful strategy for versioning is to use for example CRC checksum of the file as its version. That way your client won't need to download a whole bunch of new files, just because you have updated one file but had to increase the version for all.