3 ms·
I'd like to believe Chrome* users are usually up to date on version numbers. We could update the library cache on a different schedule from browser updates. Fin
by 3825 13y ago
I'd like to believe Chrome* users are usually up to date on version numbers. We could update the library cache on a different schedule from browser updates. Finally, we could fall back to a CDN (with further fall back to your own server?) if the server requests jQuery 2.0.1 and the browser says sorry, best I can do is 2.0.0.
My fear was more on the server-side. Can we accomplish this without further butchering the head from the standard? I can't see all browsers adopting this or it becoming a standard without a major sponsor. And like someone else mentioned, we can get about the same benefits from aggressive caching. I agree for the most part.
Don't get me wrong. I love Google. I love what they do to make the web faster with their hosted libraries[1]. Correct me if I am wrong but caching the libraries from Google only helps if the the server specifies they want that particular file from Google (I'd imagine it would be a gaping security hole any other way). My thought is whether it is possible to just declare something like 1.9.1.min.jQuery.com and have the browser just recognize it and say "Oh yes I have that. No need for a server round trip. You're welcome." or "No, I don't understand what you're talking about. Give me an address so I can fetch it."
Is it even worth it? jQuery 1.9.1 minified is ~90 kB, so we're probably just trying to shave off tens of milliseconds at the most. I bet we all have fruits hanging lower than this to worry about it. Another thing is that it will probably have to be a vendor-specific meta tag (as I don't see everyone getting aboard this, if anyone) in the header which I don't know is a good thing.
[1] https://developers.google.com/speed/libraries/ https://developers.google.com/speed/libraries/
*I believe Mozilla Firefox has also started silent updates. It'd be nice to see how quickly users update when a new build gets pushed out.
- maggit 13y agoYou could do something like: <script src="my-copy-of-jquery.1.9.2.js.min" cannonical-uri="https://jquery.com/jquery.1.9.2.js.min" hash="SHA1-blablabla" ></script> With this setup: 1. Old browsers could work as before 2. New browsers could download your resource and cache it with the cannonical-uri and calculated (not declared!) hash as cache key (no dependency on third party CDNs) 3. New browsers could serve this resource from cache if it had downloaded it before with matching cannonical-uri AND hash, disregarding src and host The hash would make sure that the jquery the user downloaded from whereever would indeed be the same jquery you are serving up. ---- Going back to your original idea, browsers could absolutely come with prepopulated caches for such resources, but they might as well fill these caches on demand. The important thing in both cases would be to allow shared caching between sites without forcing everybody to agree on which CDN is the most pleasing. Notice that the cannonical-uri is only a name, it is not supposed to be dereferenced.
- 3825 13y agoThat looks beautiful. So the hash basically says "I trust this source"? >>The important thing in both cases would be to allow shared caching between sites without forcing everybody to agree on which CDN is the most pleasing. Notice that the cannonical-uri is only a name, it is not supposed to be dereferenced. Yes, you put it much better than I could have. Thank you!