shonny-ua / gulp-rev-collector

Static asset revision data collector from manifests, with was generated from different streams and replace they's links in html template.
MIT License
150 stars 41 forks source link

File modified timestamp is not updated when file is modified #59

Open kashiraja opened 5 years ago

kashiraja commented 5 years ago

It seems the timestamp is not updated for files when the content is updated. Is this functionality outside the scope of gulp-rev-collector? Do I need to pipe another plugin to ensure this happens?

The reason why this is desirable is to ensure the timestamp is updated if the content of the file is updated (e.g. *.html). NGINX computes the etag hash for static assets which is based on last modified timestamp and the length of the file. Unless the file timestamp itself is updated, the etag will remain the same even though the hash for included bundles have been modified (because length is still the same).

On the other hand, to ensure that unmodified assets remain cached it is desirable to retain the timestamp of files that are not modified.

  const revCollector = require('gulp-rev-collector');

  [...]

  return gulp.src(['./temp/bundles/manifest.json', 'dist/app/**/*.html'], { base: "./" })
    .pipe(revCollector())
    .pipe(gulp.dest('.'));