Welcome! Log In Create A New Profile

Advanced

Re: Nginx unexpectedly returning 304 for content cached from proxy

June 08, 2009 06:26AM
On Mon, Jun 08, 2009 at 01:39:12PM +0400, Antonio L. wrote:

> Hello!
> 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 "HTTP
> 304 Not Modified" responses for some?not all?of the cached images, even if
> the browser doesn't send an If-modified-since header -- causing lots of
> broken images when viewing the site in browser.
>
> As soon as I turn off the "proxy_cache" directive and let the requests be
> proxied to the upstream server, bypassing nginx's cache, no more unexpected
> 304's are served, and the broken images disappear.
>
> Do you have any idea of what might be causing this problem?
>
> My nginx.conf file is below:
>
> ###
> worker_processes 3;
>
> error_log logs/error.log;
>
> events {
> worker_connections 10240;
> use epoll;
> }
>
> http {
> include mime.types;
> default_type application/octet-stream;
>
> access_log off;
>
> sendfile on;
> keepalive_timeout 10;
>
> gzip on;
>
> upstream backend {
> server xxx.xxx.xxx.xxx;
> }
>
> proxy_buffer_size 16k;
> proxy_buffers 8 16k;
> proxy_busy_buffers_size 32k;
> proxy_intercept_errors on;
> proxy_cache_path /var/www/cache levels=1:2
> keys_zone=zone_one:10m inactive=24h;
>
> server {
> listen 80;
> server_name localhost;
>
> location / {
> proxy_cache zone_one;
> proxy_cache_valid 200 7d;
> proxy_pass http://backend;
> }
> }
> }
> ###

This is a bug. I will try to fix in today 0.8.1.
As quick workaround, you may set any proxy_set_header directive in
cached location, e.g.:

location / {
proxy_cache zone_one;
proxy_cache_valid 200 7d;
proxy_pass http://backend;
+ proxy_set_header Host backend;
}


--
Igor Sysoev
http://sysoev.ru/en/
Subject Author Posted

Nginx unexpectedly returning 304 for content cached from proxy

antonio June 08, 2009 05:39AM

Re: Nginx unexpectedly returning 304 for content cached from proxy

merlin corey June 08, 2009 06:28AM

Re: Nginx unexpectedly returning 304 for content cached from proxy

Igor Sysoev June 08, 2009 06:26AM

Re: Nginx unexpectedly returning 304 for content cached from proxy

antonio June 08, 2009 07:58AM

Re: Nginx unexpectedly returning 304 for content cached from proxy

uqtdettr September 21, 2009 01:06AM

Re: Nginx unexpectedly returning 304 for content cached from proxy

uqtdettr October 26, 2009 09:49PM

Re: Nginx unexpectedly returning 304 for content cached from proxy

David Kostal December 17, 2009 03:54AM

Re: Nginx unexpectedly returning 304 for content cached from proxy

Ryan Malayter January 11, 2010 03:14PM

Re: Nginx unexpectedly returning 304 for content cached from proxy

arnoldguo January 21, 2010 04:38AM

Re: Nginx unexpectedly returning 304 for content cached from proxy

arnoldguo January 22, 2010 12:37AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 139
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready