我有一台运行 nginx 的服务器,该服务器为使用 ratpack 构建的 Web 应用程序提供服务,但从浏览器或使用 curl 请求网站时,我无法获得 304 响应。
Nginx 配置:
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_read_timeout 240;
proxy_pass http://example.com/;
proxy_redirect off;
add_header Last-modified "Wed, 29 Nov 2017 12:56:25";
if_modified_since before;
}
Run Code Online (Sandbox Code Playgroud)
从浏览器我总是得到 200 ok 和 curl 我得到
HTTP/1.1 302 Found
Server: nginx/1.6.3
Date: Wed, 29 Nov 2017 14:23:07 GMT
Content-Length: 0
Connection: keep-alive
location: http://example.com/display
Last-Modified: Wed, 29 Nov 2017 12:56:25
Run Code Online (Sandbox Code Playgroud)
我已经尝试了这两个 curl 命令,并且都给出了上述响应:
curl -I -H …Run Code Online (Sandbox Code Playgroud)