This is an alternative to #42, which simply removes any assets that aren't referenced by manifest.yml.
It provides a strong guarantee that the public/assets cache won't grow out of control, by clearing the cache if any exceptions are raised during the cleanup. I know it's usually not a good idea to rescue Exception, but you never know what might happen when you're dealing with 2.2 million apps. Anything could be monkey-patched by a rogue gem, and anything could break :)
Since most Rails 3 apps won't benefit from this caching unless they are using my turbo-sprockets-rails3 gem, I think it would be appropriate to add the following conditional:
# assets caching code ...
Let me know what you think about that.
Note that cache_load "public/assets" at the beginning doesn't need to be conditional, since it just won't do anything if public/assets isn't cached.
Cache public/assets, and clean unreferenced assets after precompile
Have opened a pull request with the turbo-sprockets-rails3 conditional at #44