4 ms·
Which is fantastic for "modern" web apps. We use webpack and all filenames are just sha hashes of the contents in the production builds. There is no need for t
by Klathmon 11y ago
Which is fantastic for "modern" web apps.
We use webpack and all filenames are just sha hashes of the contents in the production builds. There is no need for the browser to ever ask anything about that file again (unless its purged from the cache...).
- deleted 11y ago[deleted]
- toomuchtodo 11y agoContent addressable web! Love it!
- Klathmon 11y agoIt really works beautifully. One of our applications coming up needs to work offline, and we found that because of the naming we were using, appcache was almost completely work-free to implement. If the appcache.manifest changes, it rechecks all files (or in my case, would only pointpessly re-check those which haven't changed, and download new ones), and the appcache.manifest will change the second a single byte anywhere in the program changes. It's fantastic.
- Syrup-tan 11y agoIt's notable that appcache is now deprecated [0] It's been replaced by Service Workers, but those can get reallly hard to deal with if they start caching themselves (!) Chrome's devtools has ways to delete old service workers and such, but I've found that on Firefox it's next to impossible to debug. [0] https://developer.mozilla.org/en-US/docs/Web/HTML/Using_the_application_cache https://developer.mozilla.org/en-US/docs/Web/HTML/Using_the_...
- stqism 11y agoIt's also notable that service worker adoption is only half way at best, whereas appcache is easier to deploy and supported in far more browsers. Not to say service workers aren't the future, but implementing partially adopted features in web pages is poor practice. http://caniuse.com/#feat=serviceworkers http://caniuse.com/#feat=serviceworkers
- Klathmon 11y agoWe are aware and are ready to switch to a service-worker and appcache hybrid when that time comes that appcache is going to be removed. But until then we wanted to keep it simple. Especially during development we don't want to have to deal with differences in SW and appcache.
- lucaspiller 11y agoThis has been the standard way of serving assets in Rails for the last 5+ years. I don't think it was invented there, as if you are using a CDN it's basically required. Invalidating edge caches takes time and/or is expensive (i.e. Cloudfront), so adding the content hash in the file name is a good trick to ensure users always get the correct version of the asset.
- Klathmon 11y agoI didn't mean to imply it was invented by webpack or anything (and I used the scarequotes around modern because I'm not sure how long it's been widely used). I was just pointing out how and with what I use it.
- mitchtbaum 11y agoWhy use hashes? Wouldn't UUIDs make more sense?
- nathan_f77 11y agoHashes are generated from the contents of the files. You don't need to store UDIDs anywhere.
- STRiDEX 11y agoFrontend builds sometimes destroy the dist folder and rebuild all assets. Hash will result in the same name if it is unchanged.
- gbvb 11y agoIs there a write up on how this is implemented? I want to find out more about this model of delivering content.
- gbvb 11y agoNevermind. I should have googled first. https://medium.com/@okonetchnikov/long-term-caching-of-static-assets-with-webpack-1ecb139adb95#.drkb1rjz4 https://medium.com/@okonetchnikov/long-term-caching-of-stati...