request for the CDN's
Posted by Ian Holsman
here’s a heartfelt request for someone else to do.
Wouldn’t it be wonderful if akamai or someone else with large fat pipes offered to host some of the more common javascript libraries instead of every company forcing you to download the same thing off their server?
or better yet.. if mozilla could have a way to integrate it into their regular download.
say your page wants to use dojo 0.2. It would include a reference to something like:
<script src='cacheit:dojotoolkit.org/0.2/js/dojo.js' >
and then the user will have it for cached on their local machine. ready for the next application which uses it.
you could even use the regular mozilla update check to get new versions of it.
and possibly CDN’s like nyud.net or akamai (maybe google ?) to help spread the love.
from what I can see there are 3 or 4 popular javascript frameworks.. so your talking about 30-40M of disk space (you might need multiple versions). and if you cache it right the traffic would be minor (a 304 once a day + 1-200k when a new release hits per user) as long as the javascript libraries are quite stable it should be fine and enhance the user experience for everyone using them.
You will probably get JavaScript across domain issues. At Backbase we’ve been thinking about this scenario for a while. But if you download the JavaScript files from another domain, those JavaScript files can only load new content from THAT specific domain, and not from your own webserver domain.
On Backbase.com we’re now implementing the Mirror Image CDN service, and that is setup as a reverse proxy system: all requests for www.backbase.com go to one of the CDN caching servers, and the requests for dynamic pages are forwarded to our origin server. So all requests go to the same domain.
Any feedback is welcome.
Jep
bother.. damn browser security.
The reverse proxy idea is a good one, but not implementible on the large scale.
The idea might not be as doomed as you think, though any XMLHttpRequest talking between clients and this hosting provider would with the present javascript security model be out of the question.
Fetching code from remote locations is still very possible using time tested script tag injection, and employing the same callback technique as does JSONP, it could even be made boot the rest of your application, as would the completion callback of an XMLHttpRequest have in the typical scenario.
Even this extra bit of dynamicity could be made redundant with a well defined API common to all frameworks (added on top of them, effectively) for running a callback once the injected code has been loaded.
While such a system would preclude usage of a package system like Dojo’s directly from the CDN, I think the suggestion is a good one. A small loader script could be used to eval() in context the content from something like a JSONP request.
I would support packaging and distributing Dojo’s core features this way for users who really need it, and a short pattern would allow devs to continue to use their own custom packages with that loader.
It’s a great suggestion.
Regards
> script tag injection it is a temporary,..
> bother.. damn browser security. right way—using a Signed Script Policy. Of course, it must be more clear, simpler and very compatible than now.