我有一个非常简单的带有电子标签的控制器:
class EtagsController < ApplicationController
before_filter :require_user
def index
if stale?(:etag => current_user)
render :layout => false
end
end
end
当我在本地开发环境中运行它时,第一个请求是 200,响应中有一个 ETag。第二个请求提交回 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 乘客 3.0.19
- nginx 1.4.1
- 导轨 3.2.13
谢谢