ruby-on-rails – 带有rails 3.2 / nginx / phusion passanger的响应头中缺少电子标签

我有一个非常简单的带有电子标签的控制器:class EtagsController ApplicationControllerbefore_filter :require_userdef indexif stale?(:etag = current_user)render :layout = falseendendend当我在本地开发环...

我有一个非常简单的带有电子标签的控制器:

class EtagsController < ApplicationController
  before_filter :require_user

  def index
    if stale?(:etag => current_user)
      render :layout => false
    end
  end

end

当我在本地开发环境中运行它时,第一个请求是响应中带有ETag的200.第二个请求提交回ETag,我按预期得到304响应.

但是,当在我的暂存或生产环境中执行时,响应中没有ETag.

以下是我的登台环境中的请求和响应标头:

Request URL: /etags
Request Method:GET
Status Code:200 OK

Request Headers
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Cache-Control:max-age=0
Connection:keep-alive
Cookie:__utma=169165539.1455374302.1372358226.1372358226.1372358226.1; __utmb=169165539.1.10.1372358226; __utmc=169165539; __utmz=169165539.1372358226.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); user_credentials=4ffa15df84112d22434f121eed06c59a5c32cb9ab72cf6bf1e952a3993201b5dec2917a028d20d4b63c70a84c6a290c4d5c4673ce967efec6f139c161850bc37%3A%3A101; _session_id=d21671b70349653406442ee0716633b2
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.116 Safari/537.36

Response Headers
Cache-Control:must-revalidate, private, max-age=0
Connection:keep-alive
Content-Encoding:gzip
Content-Length:65
Content-Type:text/html; charset=utf-8
Date:Thu, 27 Jun 2013 18:37:10 GMT
Server:nginx/1.4.1 + Phusion Passenger 3.0.19
Status:200
X-Powered-By:Phusion Passenger (mod_rails/mod_rack) 3.0.19
X-Rack-Cache:miss
X-Request-Id:620c1ab99a1af7b6dde62cee77fc59fe
X-Runtime:0.205884
X-UA-Compatible:IE=Edge,chrome=1

我很难过.为什么我的暂存环境不尊重控制器中的ETag?

涉及的技术:

> Phusion Passenger 3.0.19
> nginx 1.4.1
> Rails 3.2.13

Thannks

解决方法:

看来nginx>如果为nginx启用gzip,1.3将忽略应用程序服务器中的电子标记.我们没有在nginx中找到允许我们从应用程序服务器传递e-tags并gzip响应的解决方案.我认为弱电子标签可能适用于此,但nginx目前不支持它们.

本文标题为:ruby-on-rails – 带有rails 3.2 / nginx / phusion passanger的响应头中缺少电子标签

基础教程推荐