Rails 3自动资产部署到Amazon CloudFront吗? [英] Rails 3 automatic asset deployment to Amazon CloudFront?

查看:84
本文介绍了Rails 3自动资产部署到Amazon CloudFront吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Rails 3.1中是否有可用的gem或方法可以自动将资产上传到Amazon Cloud Front并使用这些资产而不是为本地托管的资产提供服务?我想手动上传已编译的资产然后再上传很容易更改Rails应用程序配置以使用该资产主机,但是在修改资产后,需要再次手动完成向Cloud Front的上传。有什么好的方法吗?

解决方案

一定要在github上查看 asset_sync 。或在在Heroku上使用带有Rails 3.1的CDN资产主机上的Heroku开发中心文章。。 p>

与CDN自定义来源相比,使用 asset_sync 可以大大提高性能,让您的应用懒惰地编译生产中的资产或直接关闭预编译的服务您的应用服务器。但是我会这样说。我写了它。




  • 借助asset_sync和S3,您可以预编译资产,这意味着所有资产都可以在资产宿主/ CDN上使用立即

  • 仅在预编译时需要application.rb中的:assets 捆绑包,从而在生产中节省内存

  • 您的应用服务器永远不会受到资产请求的打击。您知道,您可能会花费大量的计算时间。计算。

  • 最佳实践HTTP缓存标头均已默认设置

  • 您可以通过一个额外的配置启用自动gzip压缩


Is there a gem or method available in Rails 3.1 that can upload assets to amazon cloud front automatically and use those instead of serving locally hosted ones? I guess it's easy to upload compiled assets manually and then change the rails app config to use that asset host, but when an asset is modified, the uploads to cloud front would need to be done manually again. Any good ways out there for this?

解决方案

Definitely check out asset_sync on github. Or our Heroku dev centre article on Using a CDN asset Host with Rails 3.1 on Heroku.

There is quite a big performance improvement in using asset_sync vs a CDN custom origin, letting your application lazily compile assets in production or serving them precompiled directly off your app servers. However I would say that. I wrote it.

  • With asset_sync and S3 you can precompile assets meaning all the assets are there ready to be served on the asset host / CDN immediately
  • You can only require the :assets bundle in application.rb on precompile, saving memory in production
  • Your app servers are NEVER hit for asset requests. You can spend expensive compute time on, you know. Computing.
  • Best practice HTTP cache headers are all set by default
  • You can enable automatic gzip compression with one extra config

这篇关于Rails 3自动资产部署到Amazon CloudFront吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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