For me, assets precompilation is really boring, slow and even complicated as additional configuration is necessary.
That is why I’ve made a live asset compilation so that on the first request the assets get compiled and put on the static asset path (public/assets), just like rake assets:precompile do, so that on the next request it is going to be served by Nginx.
The reason for asset precompilation in production environments isn’t just caching and speed on the first request, it’s also that you don’t want to have to have a JS environment (e.g. TheRubyRacer) in production.
And another reason for pre-compilation is that it can happen on district asset host boxes or even be pushed to a CDN which the apps use for an asset host.
assets precompilation is really boring, slow and even complicated
Agreed, however your solution only moves the slow, complicated, boringness to the realm of your users; it doesn’t get rid of them. Now instead of you having to wait for your assets to precompile before an app is deployed, your users have to wait for assets to be compiled the first time they hit a page. If you think 30 seconds is a long time to wait for compilation on push, how do you think a user will feel about a 30 second long request to your homepage?
assets precompilation is really boring, slow and even complicated
Agreed, however your solution only moves the slow, complicated, boringness to the realm of your users; it doesn’t get rid of them. Now instead of you having to wait for your assets to precompile before an app is deployed, your users have to wait for assets to be compiled the first time they hit a page. If you think 30 seconds is a long time to wait for compilation on push, how do you think a user will feel about a 30 second long request to your homepage?
It’s interesting that you mention that. In development mode (with debug assets off) the consolidated assets build and serve in milliseconds. I’m still unsure as to why the asset pre-compile takes so long.
This is because Rails 3 has issues with caching and elements may not be cleared properly. If you’re deploying Rails 4 assets on Heroku we cache these for you and the double caching actually SLOWS down your application.
This is because sprockets doesn’t generate hashes, remove whitespace, compress javascript, or compile all JS to one file.
If you don’t need any of those things then don’t use the asset pipeline, store your assets in /public and serve them individually.
We do make use of the asset pipeline, quite heavily, and dev mode does put all assets into a single file. This is why I’m unsure why minify and hash should take so much time. The asset compile takes minutes in production.