A gulp plugin for cache files by adding a hash version append their name(like a.js?v=hash).
npm install --save-dev gulp-resource-hash
var gulp = require('gulp');
var staticHash = require('gulp-resource-hash');
gulp.task('resource-hash-html', function () {
gulp.src('static/**/*.html')
.pipe(staticHash({asset: 'static'}))
.pipe(gulp.dest('dest'));
});
<link rel="stylesheet" href="main.min.css">
<script src="main.min.js"></script>
<img src="main.png" />
<link rel="stylesheet" href="main.min.css?v=8501b2b">
<script src="main.min.js?v=8501b2b"></script>
<img src="main.png?v=8501b2b" />
The path to assets in your project
The extension list need add hash version
The path to assets in your project used by create md5 file
自定义 URL 参数
是否在 URL 末尾附加原文件的扩展名