Squid代理拒绝在Vary头存在时重新validationcaching

squid.conf中

cache_effective_user squid http_access allow all # Squid normally listens to port 3128 http_port 3128 accel defaultsite=localhost no-vhost ignore-cc cache_peer localhost parent 80 0 no-query originserver name=myAccel cache_peer_access myAccel allow all # Uncomment and adjust the following to add a disk cache directory. cache_dir ufs /usr/local/var/cache/squid 100 16 256 # Leave coredumps in the first cache dir coredump_dir /usr/local/var/cache/squid minimum_expiry_time 0 

test.php的

 <?php Header( "Cache-Control: max-age=0, must-revalidate" ); $headers = getallheaders(); $ims = $headers['If-Modified-Since']; $lastModified = "Mon, 16 Apr 2012 23:01:32 GMT"; if ($ims == $lastModified) { Header( "HTTP/1.1 304 Not Modified" ); exit; } Header("Last-Modified: $lastModified"); if ($_GET["vary"]) Header("Vary: Accept-Encoding"); ?><html>hi</html> 

Squid 3.2.9,通过Homebrew安装在OSX上

Squid 3.2.9,通过Homebrew安装在OSX上

 localhost: ~ $ squid -v Squid Cache: Version 3.2.9 configure options: '--disable-debug' '--disable-dependency-tracking' '--prefix=/usr/local/Cellar/squid/3.2.9' '--localstatedir=/usr/local/var' 'CC=cc' 'CXX=c++' 'PKG_CONFIG_LIBDIR=/usr/lib/pkgconfig' 

squid -f squid.conf -d 2 -N启动squid squid -f squid.conf -d 2 -N

当服务器省略“Vary:Accept-Encoding”头部时,Squid使用If-Modified-Since条件GET重新validation/刷新其caching。 但是,当“Vary:Accept-Encoding”头文件存在时,Squid拒绝使用If-Modified-Since,而只是忽略它的caching。 为什么?

 localhost: ~ $ curl --silent -o /dev/null --dump-header /dev/stdout http://localhost:3128/test.php HTTP/1.1 200 OK Date: Wed, 17 Apr 2013 00:17:42 GMT Server: Apache/2.2.22 (Unix) DAV/2 PHP/5.3.15 with Suhosin-Patch mod_ssl/2.2.22 OpenSSL/0.9.8r X-Powered-By: PHP/5.3.15 Cache-Control: max-age=0, must-revalidate Last-Modified: Mon, 16 Apr 2012 23:01:32 GMT Content-Length: 16 Content-Type: text/html X-Cache: MISS from localhost Via: 1.1 localhost (squid/3.2.9) Connection: keep-alive localhost: ~ $ curl --silent -o /dev/null --dump-header /dev/stdout http://localhost:3128/test.php HTTP/1.1 200 OK X-Powered-By: PHP/5.3.15 Last-Modified: Mon, 16 Apr 2012 23:01:32 GMT Content-Length: 16 Content-Type: text/html Date: Wed, 17 Apr 2013 00:17:43 GMT Server: Apache/2.2.22 (Unix) DAV/2 PHP/5.3.15 with Suhosin-Patch mod_ssl/2.2.22 OpenSSL/0.9.8r Cache-Control: max-age=0, must-revalidate Age: 0 X-Cache: HIT from localhost Via: 1.1 localhost (squid/3.2.9) Connection: keep-alive localhost: ~ $ curl --silent -o /dev/null --dump-header /dev/stdout "http://localhost:3128/test.php?vary=1" HTTP/1.1 200 OK Date: Wed, 17 Apr 2013 00:17:58 GMT Server: Apache/2.2.22 (Unix) DAV/2 PHP/5.3.15 with Suhosin-Patch mod_ssl/2.2.22 OpenSSL/0.9.8r X-Powered-By: PHP/5.3.15 Cache-Control: max-age=0, must-revalidate Last-Modified: Mon, 16 Apr 2012 23:01:32 GMT Vary: Accept-Encoding Content-Length: 16 Content-Type: text/html X-Cache: MISS from localhost Via: 1.1 localhost (squid/3.2.9) Connection: keep-alive localhost: ~ $ curl --silent -o /dev/null --dump-header /dev/stdout "http://localhost:3128/test.php?vary=1" HTTP/1.1 200 OK Date: Wed, 17 Apr 2013 00:18:00 GMT Server: Apache/2.2.22 (Unix) DAV/2 PHP/5.3.15 with Suhosin-Patch mod_ssl/2.2.22 OpenSSL/0.9.8r X-Powered-By: PHP/5.3.15 Cache-Control: max-age=0, must-revalidate Last-Modified: Mon, 16 Apr 2012 23:01:32 GMT Vary: Accept-Encoding Content-Length: 16 Content-Type: text/html X-Cache: MISS from localhost Via: 1.1 localhost (squid/3.2.9) Connection: keep-alive 

对于什么是值得的,我看到了与3.3.4版本相同的问题,看来这篇文章在squid-users中描述了与3.2.1相同的问题。 我注意到它似乎与3.1.10(这是我的包pipe理器默认安装)。

通过分析日志,我可以确定存储期间使用的散列查找键(即初始请求)与后续请求期间使用的散列查找键不同。 这就是后续查找caching未命中的原因。

有了这些信息(额外的search标准),我能够find这个错误报告 ,描述这个问题。 该错误未解决。

希望这可以帮助!

这确实是一个错误,截至目前它是固定的,关于Squid的bugtracker更多的信息。