我想在我的應用程序中使用HTTP_IF_MODIFIED_SINCE頭來確定資源是陳舊/新鮮的,並在這些情況下呈現200/304。 在我的開發環境中一切正常,但我不能爲了我的生活讓它在生產中工作。HTTP_IF_MODIFIED_SINCE頭沒有傳遞給Rails應用程序(Nginx,Passenger)
我使用的是Passenger 3.0.11和Nginx 1.0.13。
正如您在下面看到的,我嘗試了proxy_pass_header,proxy_set_header,passenger_pass_header和passenger_set_cgi_param。最後一個實際設置了HTTP_IF_MODIFIED_SINCE標頭,但它是空的... 任何幫助/想法將不勝感激!
我的配置:
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;
}
}
你需要這些指令來操縱頭文件嗎?我從來不需要這樣的東西 – 2012-04-08 09:23:44
嗯,不。我沒有在應用程序中看到HTTP_IF_MODIFIED_SINCE標頭,有或沒有這些指令。 ('passenger_set_cgi_param'創建了頭部屬性,但它是空的)。也許它在Nginx之前在某處被過濾了?你可以發佈你的Nginx conf嗎? – 2012-04-08 16:51:53