We are using GruntJS to do builds on our CSS and JS files and then will usually manually insert a cache buster string into our page headers. Currently, we blow the cache on either all the CSS or JS files by adding a cache buster string to every file. Its not the best way of doing it and its quite a manual process. I found a few plugins on NPM for cache busting, but none of them did exactly what I wanted.
There is one particular plugin that I used Grunt Cache Bust. At first I forked the code, then told the author I would be adding some functionality and was going to do a pull request. But he didnt seem too keen on adding in my features. Instead I decided to just use his code as a base, but ended up changing a lot of how it worked. I would say it’s about 20% of his code and the rest was rewritten. But wanted to give credit where credit was due.
The process of writing the plugin gave me a greater understanding to how node.js and GruntJS work. I decided to call my plugin Bust My Cache, its available on NPM, Github and you can also find it through the GruntJS plugin page by searching for “bust-my-cache”.
Feel free to download it and use it as part of your project!