vendredi 30 août 2019

Can a browser check to see if it has a JS library regardless of its source and use it?

BLUFF

Can a browser be told to check to see if it already has a JS library cached from another source by using some sort of identifying metric (Hash, Signature, Version ID, etc) and then use the cached version instead of re-downloading it?

Problem

Assume that there a hundreds of devices on an offline network that have slightly different Single Page Apps (SPA) that all use the same single large JS library. They each serve both the SPA and library locally. Admins of these devices will have fast access to some devices and slow access to others. I am trying to determine if there is anyway to speed up the downloading of the SPA to the Admin's browser for the 'slow access' devices by leveraging the common use of the large library.

The ideal solution would be opportunistic. It would ask the browser if it has the large JS Library with a certain has hash (liblarge.js,sha-256: B4...X) and if it did use it, if not then load the one over the slow link.

I understand that I could try to determine the fast access devices and then try to serve the large library from them, but this would require some sort of reconnaissance along with overhead.

I also understand that I could try to put something like a CDN on the network and serve the large JS lib but there are other aspects of the offline network that make this difficult.




Aucun commentaire:

Enregistrer un commentaire