When deploying updates to your new shiny app, you're going to want the browser to fetch the latest version if there has been an update, rather than using the cached version the browser may store. The simplest way we can do this is by appending a content hash to the filename, to ensure that when you push a new update, a new hash will be created, thus invalidating the previous cached versions.
To do this, we can use a simple plugin called broccoli-asset-rev:
1 | yarn add --dev broccoli-asset-rev@^2.7.0 |
Now, update your Brocfile.js
:
1 | // Brocfile.js |
What we've done here, is add the AssetRev
plugin as the last plugin to the tree, for production builds only. It will
auto-hash js
, css
, png
, jpg
, gif
and map
files, and will update html
, css
and js
files with any
references to the original un-hashed file, with the new hashed file. There are additional options to specify a prefix
so that files can be hosted on a CDN if you wish, see the plugin github page.
Run yarn build-prod
and checkout the dist
directory:
1 | └── assets/ |
Completed Branch: 13-fingerprints
Next: 14-complete