<div class="gmail_quote">Hello!<div><br></div><div>We recently started using Nginx 0.7.59 to replace Squid on a couple of our static file caching servers (Debian 5.0). However, nginx is returning &quot;HTTP 304 Not Modified&quot; responses for some—not all—of the cached images, even if the browser doesn&#39;t send an If-modified-since header -- causing lots of broken images when viewing the site in browser.</div>

<div><br></div><div>As soon as I turn off the &quot;proxy_cache&quot; directive and let the requests be proxied to the upstream server, bypassing nginx&#39;s cache, no more unexpected 304&#39;s are served, and the broken images disappear.</div>

<div><br></div><div>Do you have any idea of what might be causing this problem?</div><div><br></div><div>My nginx.conf file is below:</div><div><br></div><div>###</div><div><div>worker_processes  3;  <br></div><div><br></div>

<div>error_log  logs/error.log;</div><div><br></div><div>events {</div><div>    worker_connections  10240;</div><div>    use epoll;</div><div>}</div><div><br></div><div>http {</div><div>    include       mime.types;</div>

<div>    default_type  application/octet-stream;</div><div><br></div><div>    access_log  off;</div><div><br></div><div>    sendfile        on; </div><div>    keepalive_timeout  10; </div><div><br></div><div>    gzip  on; </div>

<div><br></div><div>    upstream backend {</div><div>        server  xxx.xxx.xxx.xxx;</div><div>    }   </div><div><br></div><div>    proxy_buffer_size 16k;<br></div><div>    proxy_buffers 8 16k;</div><div>    proxy_busy_buffers_size 32k;</div>

<div>    proxy_intercept_errors on; </div><div>    proxy_cache_path /var/www/cache levels=1:2 </div><div>            keys_zone=zone_one:10m inactive=24h;</div><div>    </div><div>    server {<br></div><div>        listen       80; </div>

<div>        server_name  localhost;</div><div><br></div><div>        location / { </div><div>            proxy_cache zone_one;</div><div>            proxy_cache_valid 200 7d; </div><div>            proxy_pass <a href="http://backend" target="_blank">http://backend</a>;</div>

<div>        }   </div><div>    }</div><div>}</div><div>###</div><div><br></div><div>I added the &quot;proxy_cache_valid&quot; directive to only cache 200 responses, but that didn&#39;t seem to change anything (even after deleting the cache).</div>

<div><br></div><div>This is pretty much what I&#39;m seeing:</div><div><div><br></div><div>$ curl -I <a href="http://www.myserver.com/thumbs/125x100/10081/m88_1240816236.jpg" target="_blank">http://www.myserver.com/thumbs/125x100/10081/m88_1240816236.jpg</a></div>

<div>HTTP/1.1 304 Not Modified</div><div>Server: nginx/0.7.59</div><div>Date: Mon, 08 Jun 2009 09:26:05 GMT</div><div>Connection: keep-alive</div><div>Last-Modified: Mon, 27 Apr 2009 07:10:40 GMT</div><div>Expires: Wed, 08 Jul 2009 08:19:13 GMT</div>

<div>Cache-Control: max-age=2592000</div><div><br></div><div>If I disable the proxy_cache (leaving just proxy_pass in location /):</div><div><div><br></div><div>$ curl -I <a href="http://www.myserver.com/thumbs/125x100/10081/m88_1240816236.jpg" target="_blank">http://www.myserver.com/thumbs/125x100/10081/m88_1240816236.jpg</a></div>

<div>HTTP/1.1 200 OK</div><div>Server: nginx/0.7.59</div><div>Date: Mon, 08 Jun 2009 09:28:17 GMT</div><div>Content-Type: image/jpeg</div><div>Connection: keep-alive</div><div>Content-Length: 3869</div><div>Last-Modified: Mon, 27 Apr 2009 07:10:40 GMT</div>

<div>Vary: Accept-Encoding</div><div>Expires: Wed, 08 Jul 2009 09:32:33 GMT</div><div>Cache-Control: max-age=2592000</div><div>Accept-Ranges: bytes</div><div><br></div><div>I&#39;m not quite sure where to start debugging this.  Does anyone have any advice?</div>

<div><br></div><div>Thanks,</div><div>Antonio</div></div></div></div>
</div><br>