如何加快Heroku上的咖啡脚本资产编译速度

时间:2023-02-02 02:44:21

Ruby on Rails 3.2 with lots of small coffee script files take a huge amount of time to deploy:

带有大量小咖啡脚本文件的Ruby on Rails 3.2需要花费大量时间进行部署:

Is there any way to speed up asset compilation on Heroku?

有没有办法加速Heroku上的资产编译?

   Compiled backbone/apps/manage_promote/show/templates/_integrate.js  (271ms)  (pid 7108)
   Compiled backbone/apps/manage_promote/show/templates/show_layout.js  (336ms)  (pid 7108)
   Compiled backbone/apps/manage_promotions/list/list_controller.js  (260ms)  (pid 7108)
   Compiled backbone/apps/manage_promotions/list/list_view.js  (236ms)  (pid 7108)
   Compiled backbone/apps/manage_promotions/list/templates/_empty.js  (335ms)  (pid 7108)
   Compiled backbone/apps/manage_promotions/list/templates/_promotion.js  (380ms)  (pid 7108)
   Compiled backbone/apps/manage_promotions/list/templates/_promotions.js  (368ms)  (pid 7108)
   Compiled backbone/apps/manage_promotions/list/templates/list_layout.js  (284ms)  (pid 7108)
   Compiled backbone/apps/manage_promotions/manage_promotions_app.js  (238ms)  (pid 7108)
   Compiled backbone/apps/manage_promotions/new_edit/new_edit_controller.js  (267ms)  (pid 7108)
   Compiled backbone/apps/manage_promotions/new_edit/new_edit_view.js  (241ms)  (pid 7108)
   Compiled backbone/apps/manage_promotions/new_edit/templates/new_edit_layout.js  (301ms)  (pid 7108)
   Compiled backbone/apps/manage_statistics/list/list_controller.js  (264ms)  (pid 7108)
   Compiled backbone/apps/manage_statistics/list/list_view.js  (231ms)  (pid 7108)

1 个解决方案

#1


0  

Option 1: Precompile assets locally

选项1:在本地预编译资产

You can compile your assets locally, add them to source control and push them to Heroku:

您可以在本地编译资源,将它们添加到源代码管理并将它们推送到Heroku:

RAILS_ENV=production bundle exec rake assets:precompile
git add public/assets
git commit -m "Precompile assets"

Heroku will then detect the precompiled assets and skip compilation

然后Heroku将检测预编译的资产并跳过编译

-----> Preparing Rails asset pipeline
       Detected manifest.yml, assuming assets were compiled locally

See https://devcenter.heroku.com/articles/rails-asset-pipeline#the-rails-3-asset-pipeline for additional info

有关其他信息,请参阅https://devcenter.heroku.com/articles/rails-asset-pipeline#the-rails-3-asset-pipeline

Option 2: Use memcache caching for sprockets

选项2:对链轮使用memcache缓存

Via http://blog.alexmaccaw.com/faster-deploys (DISCLAIMER: I have not tried this approach.)

通过http://blog.alexmaccaw.com/faster-deploys(免责声明:我没有尝试过这种方法。)

Enable a memcache add-on

启用内存缓存加载项

heroku addons:add memcachier

Add dalli and memcachier to your Gemfile.

将dalli和memcachier添加到您的Gemfile中。

Configure asset cache store in config/environments/production.rb

在config / environments / production.rb中配置资产缓存存储

config.assets.cache_store = :dalli_store

#1


0  

Option 1: Precompile assets locally

选项1:在本地预编译资产

You can compile your assets locally, add them to source control and push them to Heroku:

您可以在本地编译资源,将它们添加到源代码管理并将它们推送到Heroku:

RAILS_ENV=production bundle exec rake assets:precompile
git add public/assets
git commit -m "Precompile assets"

Heroku will then detect the precompiled assets and skip compilation

然后Heroku将检测预编译的资产并跳过编译

-----> Preparing Rails asset pipeline
       Detected manifest.yml, assuming assets were compiled locally

See https://devcenter.heroku.com/articles/rails-asset-pipeline#the-rails-3-asset-pipeline for additional info

有关其他信息,请参阅https://devcenter.heroku.com/articles/rails-asset-pipeline#the-rails-3-asset-pipeline

Option 2: Use memcache caching for sprockets

选项2:对链轮使用memcache缓存

Via http://blog.alexmaccaw.com/faster-deploys (DISCLAIMER: I have not tried this approach.)

通过http://blog.alexmaccaw.com/faster-deploys(免责声明:我没有尝试过这种方法。)

Enable a memcache add-on

启用内存缓存加载项

heroku addons:add memcachier

Add dalli and memcachier to your Gemfile.

将dalli和memcachier添加到您的Gemfile中。

Configure asset cache store in config/environments/production.rb

在config / environments / production.rb中配置资产缓存存储

config.assets.cache_store = :dalli_store