Re:Cache across domains with a file hash
by alexchamberlain on Thursday September 13, 2012 @09:48AM
(#4516093)
Great idea! Could the browser include the libraries and authenticate them in some way?
Re:Cache across domains with a file hash
by sehrope on Thursday September 13, 2012 @09:50AM
(#4516101)
That's kind of the idea. The hash would be there so the browser could verify it is what is expected. Assuming the source page is delivered via HTTPS (w/ compression disabled :D) then the client could verify the hash against what it received to confirm it's valid.
An alternative use of this would be to validate the script that is being downloaded from the remote source. If you're delegating to Google or any other CDN for a javascript library you really expect it to be the one you requested. Assuming you're not pointing at the HEAD/latest version versus a specific (which would already be pretty amateur for a real site) then you expect it to always be exactly the same (ex: jquery-1.8.1.min.js should always be the same file ... if a bug is fixed it's a new version). It'd be a security improvement to have a way to have the browser verify that.
<script src="https://some-cdn.example.com/some-library-1.2.3.js hash="[secure hash of contents]">
If the downloaded file's hash does not match the expected one then the browser would flag a security warning or simply not load the file.