Rails 3 资产管道 +阿帕奇+ Phusion 乘客
我正在使用 Rails 3.1 w/asset pipeline、phusion 3.0.x 和 apache 2.2.17。
在 http://guides.rubyonrails.org/asset_pipeline.html 的配置文档中,第 4.1.1 节中指出我需要在我的 apache 配置中添加一个部分:
<LocationMatch "^/assets/.*$">
# Some browsers still send conditional-GET requests if there's a
# Last-Modified header or an ETag header even if they haven't
# reached the expiry date sent in the Expires header.
Header unset Last-Modified
Header unset ETag
FileETag None
# RFC says only cache for 1 year
ExpiresActive On
ExpiresDefault "access plus 1 year"
</LocationMatch>
我一直假设 Phusion Passenger 刚刚“处理”了这个......或者我疏忽了而不是 RTFM?如果我想利用指纹识别,是否需要将其添加到 apache 配置中?
I am using Rails 3.1 w/asset pipeline, phusion 3.0.x and apache 2.2.17.
In the configuration documentation at http://guides.rubyonrails.org/asset_pipeline.html, in section 4.1.1 it states that I need to add a section to my apache config:
<LocationMatch "^/assets/.*$">
# Some browsers still send conditional-GET requests if there's a
# Last-Modified header or an ETag header even if they haven't
# reached the expiry date sent in the Expires header.
Header unset Last-Modified
Header unset ETag
FileETag None
# RFC says only cache for 1 year
ExpiresActive On
ExpiresDefault "access plus 1 year"
</LocationMatch>
I have been assuming that Phusion Passenger has just been "handling" this... or have I been negligent in not RTFM? If I want to take advantage of the fingerprinting, do I need to add this to the apache config?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您想要充分利用资产管道的优势,您确实需要将其添加到您的 Apache 配置中。如果没有该部分,您的 Apache 配置可能会明确告诉浏览器不要缓存资源,从而导致浏览器和服务器之间出现不必要的往返次数。
为了使其正常工作,您可能需要启用更多 Apache 模块。为此:
要调试您的设置,我建议使用 Live Headers Firefox 插件。使用它,专门请求资产 URL(例如 http://mysite.com/assets/application-8a0ae0b2d708f797674b7123c37501ba.css)并在进行此更改之前和之后查看缓存标头。通过在任意页面上查看源代码来查找示例资源 URL。
更改后,您应该看到缓存过期时间设置为未来一年。
If you want the full benefits of the asset pipeline, you do, indeed, need to add this to your Apache configs. Without that section, your Apache configuration is likely specifically telling browsers not to cache assets - resulting in an unnecessary number of round trips between the browser and your server.
In order to get this to work, you may need to enable a few more Apache modules. To do this:
To debug your set-up, I recommend using the Live Headers Firefox plugin. Using that, specifically request an asset URL (e.g. http://mysite.com/assets/application-8a0ae0b2d708f797674b7123c37501ba.css)and look at the cache headers before and after you make this change. Find an example asset URL by doing a View Source on any page.
After the change, you should see that the cache expiration is set to one year in the future.