Heroku Cedar - 静态资产 - Rails 3.0.x [英] Heroku Cedar - Static Assets - Rails 3.0.x

查看:128
本文介绍了Heroku Cedar - 静态资产 - Rails 3.0.x的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到,当 serve_static_assets 设置为false时,heroku会在Cedar上注入一个 rails3_serve_static_assets 中间件。我在这发现的所有内容都是此初始化脚本,它与Heroku部署中提及的名称相匹配,所有它会重新启用服务的静态资产。

I've noticed that heroku injects a rails3_serve_static_assets middleware on Cedar when serve_static_assets is set to false. All I've found on this is this init script that matches the name mentioned on Heroku deploy, and all it does it re-enable the serving of static assets.

我试图找到有关Heroku如何提供这些资产的更多信息,因为它们看起来不像直接来自Rails应用程序。

I'm trying to find more information on how Heroku serves up these assets, because they don't appear to just come straight from the Rails app.

例如,当我查看js文件的标题时,它们看起来像这样:

When I look at the headers of a js file, for instance, they look something like this:

Age:0
Connection:close
Content-Encoding:gzip
Content-Type:text/css
Date:Sun, 08 Jan 2012 19:04:05 GMT
Last-Modified:Sat, 07 Jan 2012 23:43:30 GMT
Server:nginx/0.7.67
Transfer-Encoding:Identity
Via:1.1 varnish
X-Varnish:677359987

我假设 Via:1.1 varnish 表示这些资产是通过Varnish服务的,但在线文档。在这个问题上说,雪松是不可用的。

I'm assuming the Via:1.1 varnish means these assets are being served through Varnish, but the online documentation. on the matter says that Varnish is not available on Cedar.

The

The Cedar docs on gzipped responses (bottom) states that:


由于对Cedar应用程序的请求(请参阅Cedar应用程序直接向应用程序服务器发送 - 而不是通过像nginx这样的HTTP服务器代理 - 任何压缩响应都必须在应用程序中完成。

Since requests to Cedar apps are made directly to the application server – not proxied through an HTTP server like nginx – any compression of responses must be done within your application.

然而,我们可以清楚地看到,资产是根据 Content-Encoding 来gzip的。现在,我很确定 Rails 3.0.x没有 Rack :: Deflater 启用(它不会显示在耙中间件无论如何),所以我有点困惑,这个资产是如何被gzip'd的。

However we can clearly see that the asset is gzip'd according to the Content-Encoding. Now I'm fairly certain Rails 3.0.x doesn't have Rack::Deflater enabled (it doesn't show up in rake middleware anyway) so I'm a bit confused as to how this asset is being gzip'd.

这是排序的前缀到我的下一个问题有关通过Cloudfront提供这些资产的问题,但我的问题在于:

This is sort of a pre-cursor to my next question regarding serving these assets through Cloudfront, but my question here is:

有人可以解释Cedar上发生了什么:静态资产。也就是说,什么是服务我的资产(Rails,Ngnix,Varnish ??),什么是gzip'ng他们?

Can someone explain exactly what is happening on Cedar re: static assets. Namely, what is serving my assets (Rails, Ngnix, Varnish ??) and what is gzip'ng them?

推荐答案

你在标题中看到Varnish,这意味着你的域CNAME指向了proxy.heroku.com而不是proxy.herokuapp.com - Cedar上没有Varnish,但是如果你使用proxy.heroku,你会看到标题返回。 com,它会工作,但它只是一个通过。他们将由nginx提供服务。

If you're seeing Varnish in your headers it means that you have your domains CNAME pointed at proxy.heroku.com and not proxy.herokuapp.com - there is no Varnish on Cedar but you will see headers returned if you use proxy.heroku.com and it will work but it's merely a pass through. They will be being served by nginx.

这篇关于Heroku Cedar - 静态资产 - Rails 3.0.x的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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