Even if I already rake assets:precompile-ed all my assets, I still seem to have a hard to getting heroku to cache them correctly. I keep getting things like
2011-06-04T16:40:20+00:00 app[web.1]: cache: [GET /assets/application-516c0fa9926527ab92d849148e557ee6.css] stale, invalid, store
2011-06-04T16:40:22+00:00 app[web.1]: cache: [GET /assets/logo-3a84e73bd76ca1ab9629d0a92eac7d4f.png] stale, invalid, store
from my log. Although it seems like I'm getting a HTTP 304 when I inspect with firebug. Am I doing anything wrong?
To compile your assets locally, run the assets:precompile task locally on your app. Make sure to use the production environment so that the production version of your assets are generated. A public/assets directory will be created. Inside this directory you'll find a manifest.
In order to use page and action caching you will need to add actionpack-page_caching and actionpack-action_caching to your Gemfile . By default, caching is only enabled in your production environment. You can play around with caching locally by running rails dev:cache , or by setting config. action_controller.
In production, Rails precompiles these files to public/assets by default. The precompiled copies are then served as static assets by the web server. The files in app/assets are never served directly in production.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With