I would think that specifying Subresource Integrity hash on a resource should allow web browsers to cache much more aggresively, and basically always reuse the local copy of the resource.
Is stronger caching for SRI resources implemented (or at least "planned to be implemented") in browsers? So that for example hitting a "[Refresh Page]" button would still make a browser reuse the cached resource? Or is it not? If not, then is it because of some important reasons? Or just "not yet there, but yeah maybe some day"?
In general, most modern browsers will cache JavaScript files. This is standard practice for modern browsers and ensures an optimized loading experience. Cached assets such as JavaScript will typically be served from the browser's cache instead of making another request for a resource that has already been retrieved.
The browser cache is a mechanism used by browsers to store locally web page resources. This adds performance gains, minimises bandwidth consumption and overall creates a snappier experience. In this article, we explain how browser caching works and how to implement it on your website.
How to use subresource integrity. Once a browser comes across a resource using SRI, it will handle it in the following manner: The browser downloads and compares the resource (script or style sheet) to the expected hash in the integrity value before executing it.
Right-click a file in the File Explorer, select Send to…, and then select sri-hash . You will see the integrity value in a command box. Select the integrity value and right-click to copy it to the Clipboard. Press any key to dismiss the command box.
Inspired by @sideshowbarker's comment (thanks!), I browsed the W3C's issue tracker for SRI, and lo and behold, this idea is already tracked, as:
#22 — Consider shared caching
Implementing this caching idea is apparently indeed non-trivial with regards to security and privacy (e.g. because it could be used for tracking whether user visited a page). Thus, I assume, not yet (if ever) in browsers (though I still can't be 100% sure based on that). And not even yet determined if possible to be implemented in a "safe" way.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With