<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://weblogs.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Cache sharing between sites</title><link>http://weblogs.asp.net/bleroy/archive/2008/04/04/cache-sharing-between-sites.aspx</link><description>There's been some debate recently about good ways that we could enable web sites to share the browser cache in the future. The problem is that popular JavaScript frameworks currently end up being downloaded several times from different sites that use</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>re: Cache sharing between sites</title><link>http://weblogs.asp.net/bleroy/archive/2008/04/04/cache-sharing-between-sites.aspx#6227325</link><pubDate>Wed, 28 May 2008 23:29:43 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6227325</guid><dc:creator>Bertrand Le Roy</dc:creator><author>Bertrand Le Roy</author><description>&lt;p&gt;@Jonah: Some have expressed privacy concerns over having scripts hosted by Google (which then gets a lot of free information about people browsing your site through the referrer header). You also have to trust the central location to always be available. But yes, centralized hosting by Google and others is a step in the right direction.&lt;/p&gt;
&lt;p&gt;I would prefer a solution such as the ones described here because there is no such reliance on a centralized location, yet the scripts get cached across sites and the load is naturally distributed.&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6227325" width="1" height="1"&gt;</description></item><item><title>re: Cache sharing between sites</title><link>http://weblogs.asp.net/bleroy/archive/2008/04/04/cache-sharing-between-sites.aspx#6167854</link><pubDate>Thu, 08 May 2008 02:49:12 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6167854</guid><dc:creator>Jonah Dempcy</dc:creator><author>Jonah Dempcy</author><description>&lt;p&gt;Why not just rely on Google to provide the bandwidth and simply have them host all the major JS frameworks? They are already hosting plenty of code snippets on Google Code and they offer hotlinks (the link actually has the text &amp;quot;Hotlink/Download&amp;quot; so they intend for you to use it directly if you so desire).&lt;/p&gt;
&lt;p&gt;For example, I have used Dean Edwards&amp;#39; IE7.js library. Normally I would concatenate it together with all the other JS as part of the build process to minimize I/O traffic, but I&amp;#39;m wondering if I&amp;#39;d be better off just hotlinking to Google Code, on the off-chance that other sites are doing the same and the download would be cached:&lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://ie7-js.googlecode.com/svn/version/2.0"&gt;ie7-js.googlecode.com/.../2.0&lt;/a&gt;(beta)/IE7.js&lt;/p&gt;
&lt;p&gt;For now, I will keep doing my concatenation thing because minimizing the amount of separate JS files seems to have the greatest benefit (and I doubt many people have the IE7.js file cached). But, if Google Code were to host MooTools, jQuery or Prototype I&amp;#39;d be all over it in a flash. I&amp;#39;d stop having to write build scripts that combine those files with the rest of the site JS and be able to just hotlink from Google, basking in the benefits of universal caching for popular pieces of code.&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6167854" width="1" height="1"&gt;</description></item><item><title>re: Cache sharing between sites</title><link>http://weblogs.asp.net/bleroy/archive/2008/04/04/cache-sharing-between-sites.aspx#6080410</link><pubDate>Wed, 09 Apr 2008 23:13:29 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6080410</guid><dc:creator>Kurisu</dc:creator><author>Kurisu</author><description>&lt;p&gt;I hadn&amp;#39;t actually read the linked articles before commenting. Now I see he even mentions base32 encoding of the hash which kinda shows where Doug got this idea from.&lt;/p&gt;
&lt;p&gt;I think what Brendan meant is similar to DTD URIs in XML. These can be normal HTTP URLs and it&amp;#39;s certainly useful to avoid namespace clashes. A few parsers do/did really try to fetch the DTD from such URLs if it wasn&amp;#39;t stored locally. This can easily cause an unintended DDoS. Likewise it&amp;#39;s only safe if you can trust DNS and the server. So signing the scripts using PKI and/or use of TLS is probably implicitly given. Anything would mean someone misunderstood cross-site scripting. If you use only signatures i.e., you trust everything signed with certain keys but no explicit hashes that means of course the script can be modified by the key owner for good or for bad.&lt;/p&gt;
&lt;p&gt;The DDoS issue could be circumvented by using Coral: www.coralcdn.org&lt;/p&gt;
&lt;p&gt;All in all, I believe both suggestions are actually complementary.&lt;/p&gt;
&lt;p&gt;This article is also related and somewhat interesting:&lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://changelog.ca/log/2006/06/17/gnutella_does_not_need_the_x-alt_http_header"&gt;changelog.ca/.../gnutella_does_not_need_the_x-alt_http_header&lt;/a&gt;&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6080410" width="1" height="1"&gt;</description></item><item><title>re: Cache sharing between sites</title><link>http://weblogs.asp.net/bleroy/archive/2008/04/04/cache-sharing-between-sites.aspx#6075770</link><pubDate>Tue, 08 Apr 2008 21:14:49 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6075770</guid><dc:creator>Bertrand Le Roy</dc:creator><author>Bertrand Le Roy</author><description>&lt;p&gt;@Kurisu: thanks for the pointers. I agree that crypto hash attacks are blown way out of proportion by Brendan, who tends to generate a quite powerful RDF. That he would be using a security argument to dismiss Doug's approach and propose his own approach which has a much bigger security problem is quite puzzling. And yes, Doug's post wasn't limited to script and neither should any implementation of that stuff. CSS and images would benefit from the same optimizations. To cite the post above, &amp;quot;all elements that have a &amp;quot;src&amp;quot; or &amp;quot;href&amp;quot; attribute&amp;quot;.&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6075770" width="1" height="1"&gt;</description></item><item><title>re: Cache sharing between sites</title><link>http://weblogs.asp.net/bleroy/archive/2008/04/04/cache-sharing-between-sites.aspx#6075251</link><pubDate>Tue, 08 Apr 2008 16:55:46 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6075251</guid><dc:creator>Kurisu</dc:creator><author>Kurisu</author><description>&lt;p&gt;A lot of storage systems use exactly this concept i.e., storing hashes of files or chunks thereof along with the files themselves and use this to avoid transferring or sometimes even storing the same data more than once. Not surprising very similar ideas have been around for years and decades. Consider the ETag header, the Content-MD5 header or much closer RFC 2169:&lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://www.faqs.org/rfcs/rfc2169.html"&gt;www.faqs.org/.../rfc2169.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The Gnutella network takes advantage of this RFC.&lt;/p&gt;
&lt;p&gt;Calling cryptographic hashes too weak for this purpose borders on reality distortion field. How do these people think cryptographic signatures or SSL/TLS works? Not to mention that attacking the hashes by trying to generate evil twins is the least probable attack vector. Anyway, in this context though I&amp;#39;d consider it a total pain for maintenence. At the very least it would require dedicated tools to keep everything consistent during updates. Also if I was going through all this hassle I&amp;#39;d extend this to all files not just JavaScript. For browsers or proxies that already implement caching this would be a low-hanging fruit anyway. All they need to add is an index with the hashes for the cached files.&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6075251" width="1" height="1"&gt;</description></item><item><title>re: Cache sharing between sites</title><link>http://weblogs.asp.net/bleroy/archive/2008/04/04/cache-sharing-between-sites.aspx#6069725</link><pubDate>Sat, 05 Apr 2008 21:52:17 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6069725</guid><dc:creator>Bertrand Le Roy</dc:creator><author>Bertrand Le Roy</author><description>&lt;p&gt;@Joe: yes, I actually read Brendan&amp;#39;s answer before I wrote that post, but I don&amp;#39;t see how it answers my question. I reformulated with another comment that for some reason he chose not to publish. That&amp;#39;s why I posted my comments on my own blog ;) The attack scenario that I describe in this post, unless I&amp;#39;m mistaken, is not mitigated by his answer in any way as the src value would never be hit if something is already in the cache for the shared value, which may be a malicious script.&lt;/p&gt;
&lt;p&gt;@Philip: I think the third solution that I describe doesn&amp;#39;t have this flaw at all. But Doug&amp;#39;s approach is much more difficult to compromise than Brendan&amp;#39;s: the scenario with his approach is that the cache is organized as a dictionary of hashes to scripts. When you visit a page, if there is a script with a hash attribute, the browser looks up that hash and if it finds it it uses the script. But the way the cache is being constructed is what guarantees the integrity of the hash: the first time a script is loaded, the browser computes the hash locally from the contents and uses the computed hash as the key in the dictionary. Does that clarify?&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6069725" width="1" height="1"&gt;</description></item><item><title>re: Cache sharing between sites</title><link>http://weblogs.asp.net/bleroy/archive/2008/04/04/cache-sharing-between-sites.aspx#6069481</link><pubDate>Sat, 05 Apr 2008 18:51:45 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6069481</guid><dc:creator>Philip</dc:creator><author>Philip</author><description>&lt;p&gt;I don&amp;#39;t see the security difference between the two plans: how do you guarantee that the hash &amp;quot;generated with a well-defined cryptographic hash algorithm&amp;quot; really matches the javascript file referenced by the src attribute? To do that, you would have to have the browser compute the hash after receiving the javascript file (and then, why are you specifying it in the html in the first place?).&lt;/p&gt;
&lt;p&gt;The two plans are equally insecure and share the attack that you describe.&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6069481" width="1" height="1"&gt;</description></item><item><title>re: Cache sharing between sites</title><link>http://weblogs.asp.net/bleroy/archive/2008/04/04/cache-sharing-between-sites.aspx#6067644</link><pubDate>Sat, 05 Apr 2008 05:18:17 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6067644</guid><dc:creator>Joe Chung</dc:creator><author>Joe Chung</author><description>&lt;p&gt;Brendan responded to your question in his blog. &amp;nbsp;For your readers&amp;#39; convenience:&lt;/p&gt;
&lt;p&gt;&amp;quot;Only the @shared value would be shared among script tags. The @src would be loaded only if there was no cache entry for @shared.&amp;quot;&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6067644" width="1" height="1"&gt;</description></item></channel></rss>