繁体   English   中英

Nginx / PHP:发送Etag标头时,Nginx没有返回304响应

[英]Nginx/PHP : Nginx is not returning a 304 response when sending Etag header

我正在尝试使用ETags和nginx(1.2.1)服务器来理解本地缓存,该服务器将php的请求重定向到php-cgi deamon。

这里我简单的index.php:

<?php
header('Cache-Control: public');
header('Etag:"5954c6-10f4-449d11713aac0"');

echo microtime(true);

在第二次请求后,我的浏览器发送一个If-None-Match标头:

Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4
Cache-Control:max-age=0
Connection:keep-alive
Host:cache.loc
If-None-Match:"5954c6-10f4-449d11713aac0"

但是我的网络服务器没有返回304:

HTTP/1.1 200 OK
Server: nginx/1.2.2
Date: Thu, 12 Jul 2012 11:46:03 GMT
Content-Type: text/html
Transfer-Encoding: chunked
Connection: keep-alive
X-Powered-By: PHP/5.3.12
Cache-Control: public
Etag: "5954c6-10f4-449d11713aac0"
Cache-Control: public

除非我误解了,否则我的服务器应该将Etag与发送的If-None-Match进行比较并返回304响应,因为它们是相同的。

我哪里错了? 我应该在我的PHP脚本中将Etag与If-None-Match进行比较,因为nginx(或Apache)本身不能完成这项工作吗?

此致,Manu

如果你自己使用php实现这个, 也负责发送304 Not Modified。

因此,将If-None-Match标头与您的ETag进行比较,并使用header()发送回304。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM