HTTP_IF_MODIFIED_SINCE标头未传递给Rails应用程序(Nginx,Passenger) [英] HTTP_IF_MODIFIED_SINCE header not passed to Rails app (Nginx, Passenger)
问题描述
我正在尝试在我的应用中使用HTTP_IF_MODIFIED_SINCE标头来确定资源是否陈旧/新鲜,并在这些情况下渲染200/304。
在我的开发环境中,一切正常,但我不能为我的生活让它在生产中工作。
I am trying to use the HTTP_IF_MODIFIED_SINCE header in my app to determine if resources are stale/fresh and render 200/304 in those cases. In my dev environment everything works fine but I can't for the life of me get it to work in production.
我正在使用Passenger 3.0.11和Nginx 1.0.13。
I am using Passenger 3.0.11 and Nginx 1.0.13.
如下所示,我尝试了proxy_pass_header,proxy_set_header,passenger_pass_header和passenger_set_cgi_param。最后一个实际上设置了一个HTTP_IF_MODIFIED_SINCE标题,但它是空的...
任何帮助/想法将不胜感激!
As you see below, I tried proxy_pass_header, proxy_set_header, passenger_pass_header and passenger_set_cgi_param. The last one actually sets a HTTP_IF_MODIFIED_SINCE header but it is empty... Any help/ideas would be greatly appreciated!
我的配置:
server {
listen 80 default_server;
root /home/rails/myapp/current/public;
passenger_enabled on;
charset utf-8;
proxy_pass_header If-Modified-Since;
proxy_set_header If-Modified-Since $http_if_modified_since;
passenger_pass_header If-Modified-Since;
passenger_set_cgi_param HTTP_IF_MODIFIED_SINCE $http_if_modified_since;
if (-f $document_root/system/maintenance.html) {
rewrite ^(.*)$ /system/maintenance.html break;
}
location ~ \.(aspx|jsp|cgi)$ {
return 410;
}
location ~ ^/(assets)/ {
# http://guides.rubyonrails.org/asset_pipeline.html#server-configuration
# gzip_static on;
expires 1y;
add_header Cache-Control public;
add_header Last-Modified "";
add_header ETag "";
break;
}
}
推荐答案
这毕竟是用户错误。我以错误的格式将标题发送到应用程序( IF_MODIFIED_SINCE
而不是 If-Modified-Since
)。在确定之后,它没有任何额外的指令。
This was a user error after all. I sent the header to the app in the wrong format (IF_MODIFIED_SINCE
instead of If-Modified-Since
). After fixing that, it worked without any of the extra directives.
这篇关于HTTP_IF_MODIFIED_SINCE标头未传递给Rails应用程序(Nginx,Passenger)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!