Busting Cache with Asset Hash
March 27, 2017
While there are plenty of quirky nooks to browsers like different standards and behaviors, browsers also provide developers with some useful, practical tools. One of these is HTTP Caching and is a god-send especially as a website grows in complexity.
There are a few techniques to bust cache with the most widely adopted being the technique called asset hashing. The process involves creating a random string of letters and numbers, appending it to the end of all filenames, and in some cases using URL helpers to keep the HTML links up-to-date. By changing the filename each time the resource is updated, the browser is forced to load the new resource instead of refer back to the cached version. Additionally, this method is available with the most popular tools such as Webpack, Sprockets, and NPM so the process can be set to happen automatically on build – so simple!