Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do web browsers cache resources with Subresource Integrity (SRI) differently?

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"?

like image 881
akavel Avatar asked May 29 '18 08:05

akavel


People also ask

Do browsers cache scripts?

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.

What is browser caching What value does it provide?

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 do you implement Subresource integrity Sri?

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.

How do you use SRI?

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.


1 Answers

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.

like image 186
akavel Avatar answered Oct 31 '22 14:10

akavel