shonny-ua/gulp-rev-collector

File modified timestamp is not updated when file is modified

Opened this issue · 0 comments

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('.'));