ruby-on-rails – Rails 3资产管道Apache Phusion Passenger
发布时间:2020-12-16 23:15:16 所属栏目:百科 来源:网络整理
导读:我正在使用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 stil
我正在使用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配置中? 解决方法
如果您想要资产管道的全部好处,您确实需要将其添加到Apache配置中.如果没有该部分,您的Apache配置可能会特别告诉浏览器不要缓存资产 – 导致浏览器和服务器之间不必要的往返次数.
为了使其工作,您可能需要启用一些Apache模块.去做这个: sudo a2enmod # Choose headers sudo a2enmod # Choose expires sudo service apache2 restart 要调试您的设置,我建议使用Live Headers Firefox插件.使用它,特别请求资产URL(例如http://mysite.com/assets/application-8a0ae0b2d708f797674b7123c37501ba.css)and在您进行此更改之前和之后查看缓存标头.通过在任何页面上执行查看源来查找示例资产URL. 更改后,您应该看到缓存过期设置为将来一年. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |