Heroku rails 3.1应用程序 - 在编译段落时本地编译资产与编译资产 [英] Heroku rails 3.1 app - compiling assets locally vs compiling assets during slug compilation

查看:104
本文介绍了Heroku rails 3.1应用程序 - 在编译段落时本地编译资产与编译资产的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在支持资产管道的Heroku Cedar堆栈上运行rails 3.1应用程序。 Heroku 列出3种方式来编译资产


    在本地编译资产
  1. 编译段落编译期间的资产。

  2. 在运行时编译资产。 ol>

    显然#3对性能不利,Heroku文档也建议不要。但我不确定#1和#2之间哪个更好。



    #1要求您运行 rake assets:precompile 并在git中包含你的 public / assets 文件夹。你的slu will会更大,但我认为部署网站的停机时间会更短。但更大的弹头大小意味着应用程序启动速度较慢,所以也许这是一次洗。

    #2将使部署更新需要更长的时间,因为在Heroku一侧进行了预编译。然而,你会有一个更小的slu and,而且管理/记住的次数也更少。



    我的问题是 - 哪个选项(#1或#2)最好生产和为什么?



    到目前为止,它看起来像选项#2,但我想确保我没有忽略某些东西。 b $ b

    解决方案

    我在这里解决了一些这些问题和一个大问题: Rails 3.1.1资产管道Heroku缓存陷阱



    I如果它对我有效,我宁愿选择#2,这样我就不必检查编译的资产,这会使git仓库膨胀。

    在slug编译期间编译资产不会导致任何额外的停机时间,因为你现有的应用程序将保持直到slu comp编译完成,所以不用担心。



    如果你能使它工作,我的建议是#2您。如果你最终以#1开头,那么采取最佳做法是在耙子资产之前对rm -r public / assets进行git:预编译以确保没有剩余。


    I'm running a rails 3.1 app on Heroku Cedar stack which supports the asset pipeline. Heroku lists 3 ways to compile assets

    1. Compiling assets locally.
    2. Compiling assets during slug compilation.
    3. Compile assets during runtime.

    Obviously #3 is bad for performance and Heroku docs also recommend against it. But I'm not sure which is better between #1 and #2.

    #1 requires that you run rake assets:precompile and include your public/assets folder in git. Your slug will be bigger but I assume the downtime for deploying a site will be lower. But bigger slug size means slower app startup so maybe it's a wash.

    #2 will make it take longer to deploy updates because of precompile being done on Heroku side. However, you will have a smaller slug and there's less to manage/remember.

    My question is - which option (#1 or #2) is the best for production and why?

    So far it looks like option #2 but I want to make sure I'm not overlooking something.

    解决方案

    I addressed some of these issues and a big gotcha in my question here: Rails 3.1.1 asset pipeline Heroku caching gotcha

    I'd prefer #2 if it worked for me so I don't have to checkin compiled assets which just bloats the git repository.

    Compiling assets during slug compilation won't result in any additional downtime because your existing app will stay up until slug compilation is complete so no worries there.

    My advice would be #2 if you can make it work for you. If you do end up going w/ #1 then take best practice would be to git rm -r public/assets before rake assets:precompile to make sure no cruft remains.

    这篇关于Heroku rails 3.1应用程序 - 在编译段落时本地编译资产与编译资产的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆