Simple cache-breaker plugin for gulp, appends a timestamp or md5 hash to any urls.
This plugin based on cache-breaker.
You can customize output strings by changing option.
Please refer to cache-breaker, and grunt-cache-breaker.
<!-- input index.html -->
<meta charset="utf-8">
<title>CACHE BREAK</title>
<link rel="stylesheet" href="css/main.css">
<script defer src="js/libs.js"></script>
<script defer src="js/main.js"></script>
// gulp setting
var cacheBreak = require('gulp-cache-break');
gulp.task('cache-breake', function() {
gulp.src(['index.html'])
.pipe(cacheBreak({
match: ['main.js', 'main.css']
}))
.pipe(gulp.dest('public'));
});
<!-- output public/index.html -->
<meta charset="utf-8">
<title>CACHE BREAK</title>
<link rel="stylesheet" href="css/main.css?rel=1438015738280">
<script defer src="js/libs.js"></script>
<script defer src="js/main.js?rel=1438015738280"></script>