Rails 3.1 assets caching on heroku Rails 3.1 assets caching on heroku heroku heroku

Rails 3.1 assets caching on heroku


This blog post has good answers and several options. The blog post doesn't look to serious, but this is a recommended read.

full url:http://jimmycuadra.com/posts/the-challenge-of-asset-packaging-on-heroku

Letting Varnish cache and serve it as static content is brilliant, no need for rake tasks precompiling.

UPDATE 20th march 2012

the world changes fast. the Cedar stack at heroku is built for this. heroku create myapp --stack cedar Remember to add this line of code in your application.rb to compile on deploy.

config.assets.initialize_on_precompile = false 

/UPDATE


You can also try this neat Rails gem called AssetHat; It utilises caching and is super easy to setup.


For someone landing here, running his own nginx, here's how you do it:

location ~ "^\/assets\/[^.]+-[a-z0-9]{32}\." { expires max; }

from @cgriego

But that doesn't help us on Heroku :-)

On the other hand after looking into it a little, I'll just use a CDN. I will then configure my app with config.action_controller.asset_host.

Once again, Heroku makes it easier to go with the best practices!