Josiah / gulp-cachebust

Generates checksums and renames references to files, useful for cachebusting
30 stars 11 forks source link

hash entire directories #17

Open nschloe opened 8 years ago

nschloe commented 8 years ago

gulp-cachebust is the best cache busting library for gulp I know of, and we're using it happily.

Now, a peculiar use case has cropped up: We serve a number of static assets, in particular MathJax, which contains JS code tjat cannot be included in our index.js. Hence, we need to ship a JS directory with lots of files. We would like to apply gulp-cachebust here as well, but can't since we don't know which files to resources() first, which files to references() then.

A possible solution here would be to hash an entire directory, e.g., assets/mathjax into assets/mathjax-54677eb33. That would mean that if one file in the directory changes, the cache for all files in the directory is invalidated, but this is fine since it corresponds with the notion of "updating a package".

We could apply this not only to mathjax, but to all the assets that we don't bundle. (pdfjs, roboto, fontawesome come to mind.)

Josiah commented 8 years ago

gulp-cachebust probably isn't the right thing for you here. Ideally you're going to want to be 'cache busting' based on the version of the library - which semver is perfect for.