377

I’ve been pretty heads down the last two weeks - not responding to emails, avoiding IM and IRC. But for good reason. There were some important changes we needed to make to the build system for SproutCore 1.0. Despite our best efforts, every change we introduced just seemed to introduce more bugs.

This was mostly due to the fact that the build tools for SproutCore started out as a simple set of enhancements to Rails.  Since then, they’ve grown up quite a bit.  It turns out there are quite a few very arcane details that you need to get right in order to make your app download and cache well across all the different browsers and proxies out there.  Without the build tools, it would take you months of tuning and writing helper libraries to get it right.  With the build tools, it happens automatically.

We dropped Rails from our build stack over 18 months ago, switching to  a pure ruby library with a development server hosted on Merb.  The tools today are fairly sophisticated and in the future they will only become more so as we add things like static analysis and JS optimization to our tool chain.  Because of this, it was time to bite the bullet and bring the code quality up to match this new level of sophistication.

That is why over the holidays and the month of January I undertook the task of rewriting the build tools from scratch.  The new code introduces a few small new features, but its biggest new feature is not part of the mainline code at all.  It is the 377 (and growing!) unit tests that come along with it.  With these unit tests, we can now make changes to the build tools and accept build tools improvements from the community without worrying as much about breaking existing projects.  That is something to get excited about!

I still need to stabilize some things over the next few weeks and then we will postback the new tools.  I think you’re going to love them.

SproutCore 0.9.21 - A Better World Through Caching Release

We released a new version of the SproutCore build tools today.  Version 0.9.21 does not contain any of the new bitburger code, but it does include one important change for caching.

Previously, if you looked at the source of your SproutCore applications, you might have seen URL references like this:

/sproutcore/en/javascript.js?1a2ef30ab23980

The number after the question mark is a cache code.  It’s purpose was to help web browsers notice when the version of an asset (such as your JavaScript) has changed.  This way the server, and caching proxies in between, could store your static assets in cache, reducing the load time for your app.

The problem with this approach (which is commonly used in Rails and other popular web frameworks, by the way) is that some proxies on the web are misconfigured to ignore this cache code if the resource you are requesting ends in a “static” resource extension such as .js, .html, etc.  The result was that some proxies would keep your old assets cached when you deployed new versions, even if your cache code changed.

0.9.21 fixes this problem by moving the cache code into the URL itself as a build number.  If you install the new build tools and rebuild your application, you will now see URLs like above transformed to:

/sproutcore/en/1a2ef30ab23980/javascript.js

The number included there is actually a build number, automatically generated by SproutCore when you performed the build.  This build number will change automatically whenever you change any of your source code.  Since this build number is part of your actual URL, proxies will properly load your new content when you deploy it.  Problem solved.

Although this change was intended primarily to force the proper caching behavior for all proxies, you now get some extra cool new benefits with the new build tools.  For one thing, the number defined above is actually a “build number”.  Although SproutCore can calculate a build number for you, if you already use build numbers to track releases internally, you can easily set this build number yourself by passing the –build option to sc-build.  See sc-build –help for more info.

Additionally, this new model means that you can now easily deploy multiple versions of a single bundle (such as SproutCore or your app) and they won’t clobber eachother.  Each one will end up in its own build.

How to Make the Most of Your Caching

If you are not doing it already, caching support is one of the key techniques used by virtually every large website to maximize their performance.  SproutCore is designed specifically to work with this.  To achieve the best performance on your application, be sure to set your web server so that all assets EXCEPT for the index.html are served with the following header added:

Expires: <10 years from now>

Consult your web server docs for how to set this header.  The <10 years from now> part, of course, is automatically inserted by your web server.

By setting this cache header, you will be telling web browsers and any proxies in between that it is OK for them to download your static assets one time and then to never even ask you for them again.  This means that, best case, a user who has visited your SproutCore application one time will the next time download ONLY your index.html file and nothing else.  It’s really zippy!

It is important that you not set this header on your index.html files.  If you do, then a user may never get an updated version of your application when you deploy it, since you will have effectively told the browser not to check back with you.

How to Get the Update

If you have SproutCore installed already, get the new buildtools by running:

sudo gem update sproutcore,

from the command line.  Otherwise, see our download page for more info.

Who Needs Flash? - Real Link

If you thought the video’s of Peter Bergstrom’s PaperCube were nice, try checking it out for yourself! Peter is gracously hosting it publicly for everyone to try.

For the best experience, try using PaperCube in Safari or Webkit. Firefox is also good, but the experience is better in Webkit. Search for “Hypertext” and look for a paper with lots of citations. Then have fun!

Try PaperCube »

SproutCore Workshops

Over the last year, Erich Ocean, one of the core SproutCore developers, has offered an intensive one-day workshop to a few companies he has worked with in the past.  Companies that worked with him really felt the training helped them reach their development target much faster and with less pain.

Now we would like to extend that training to everyone else by taking the SproutCore Workshop “on the road”.  To that end, we’d like your help in planning the cities and content of this workshop by completing a short survey.

If you think you might be interested in learning more about SproutCore from the people who are writing the framework, please take a few minutes to complete this survey to make sure your needs are represented!

Take the SproutCore Workshop Survey »

Who needs Flash?

Peter Bergstrom has been doing some amazing work with SVG and canvas tags in his SproutCore-based these project called PaperCube.  PaperCube visualizes citations their relationships between authors.  Watching the videos of his project, you’d swear he was using Flash or Silverlight, but its not.  He’s using only native web technologies powered by SproutCore and JavaScript.  It’s a great example of what’s possible using the browser’s capabilities today.

Checkout PaperCube’s Node Graph (SVG),  Per Year View (SVG), and Paper Tree (pure HTML).

Screenshot