Asset Consoles Upgrading to Rails 3.1 on Heroku

I just updated my application on Heroku from Rails 3.0 to 3.1, and I'm trying to do the pipeline work. The main problem is that I can read the following lines from heroku log for each asset:

2011-09-03T16:35:28+00:00 app[web.1]: cache: [GET /assets/border-a3c571a354b9381740db48aeebfaa63a.jpg] miss 

If I understand the pipeline correctly, this should not be "skipped" for every request that I make from the browser, but it needs to be found in the cache.

When reading Heroku docs, you can find this explanation:

 Rails 3.1 provides an assets:precompile rake task to allow the compilation penalty to be paid up front rather than each time the asset is requested. If this task exists in your app we will execute it when you push new code. 

But how should this asset: precompilation task be? I tried to build a project with 3.1 rails from scratch to try to figure out, but there is no such problem in a bare project. Or am I missing something? How can I make the assets found in the cache? Perhaps this is just a configuration issue.

These are the parameters of my configuration file:

 config.serve_static_assets = false config.assets.compress = true config.assets.compile = true # If I turn this off I get a 500 error and logs say that an asset isn't compiled 

My application.rb has the following line:

 config.assets.enabled = true 

Many thanks for your help!

+5
source share
4 answers

I was wondering the same thing, but here is a hint to help you figure out if your assets are compilation or not.

  • run rake assets:precompile locally
  • make some changes to your css but don't restart the rake command
  • git add, commit and click on the hero

If the changes you made in step 2 are displayed on the hero, then you know that your application is running in real time

Remember that you are now responsible for http caching, since Varnish is no longer included in the celadon, so you need to configure cache cache and memcached yourself:

But yes, I also found this perplexity

+4
source

Also, see http://guides.rubyonrails.org/asset_pipeline.html#precompiling-assets

For faster pre-compilers, you can partially download the application by setting config.assets.initialize_on_precompile to false in config / application.rb, although in this case the templates do not see application objects or methods. Geroku demands that it be false

+5
source

Can you try with config.serve_static_assets set true and

 config.action_dispatch.x_sendfile_header = "X-Sendfile" 

added to your config/environments/production.rb file?

When you click your code on Heroku, you should see the precompilation declared by the slug AFAICT compiler.

+1
source

Make sure you are on the Kerok Heroku stack . Heroku will then automatically precompile your assets during bullet compilation .

Note. I still get "cache misses," but I don’t think it is true, because your application will not work if your assets were not compiled.

+1
source

Source: https://habr.com/ru/post/917605/


All Articles