# Re: Nginx unexpectedly returning 304 for content cached from proxy

**URL:** <https://www.ruby-forum.com/t/re-nginx-unexpectedly-returning-304-for-content-cached-from-proxy/180458>\
**Category:** NGINX\
**Created:** [December 19, 2009, 3:25pm UTC](https://www.ruby-forum.com/t/re-nginx-unexpectedly-returning-304-for-content-cached-from-proxy/180458 "2009-12-19T15:25:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ntk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/48db29/32.png) [@ntk](https://www.ruby-forum.com/u/ntk)\
**Post date:** [December 19, 2009, 3:25pm UTC](https://www.ruby-forum.com/t/re-nginx-unexpectedly-returning-304-for-content-cached-from-proxy/180458/1 "2009-12-19T15:25:42Z")

</div>

Hi,  
i just hit the same issue as is described in  
[Nginx unexpectedly returning 304 for content cached from proxy - NGINX - Ruby-Forum](http://www.ruby-forum.com/topic/188902) with nginx 0.7.64. Also the  
workaround  
proxy\_set\_header If-None-Match “”;  
does work properly.

I think the problem is just one typo in a source code, please check  
the attached patch.

---

<div class="post-metadata">

**Author:** ![ntk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/48db29/32.png) [@ntk](https://www.ruby-forum.com/u/ntk)\
**Post date:** [January 11, 2010, 9:08pm UTC](https://www.ruby-forum.com/t/re-nginx-unexpectedly-returning-304-for-content-cached-from-proxy/180458/2 "2010-01-11T21:08:43Z")

</div>

On Thu, Dec 17, 2009 at 2:50 AM, David K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Hi,  
> i just hit the same issue as is described in  
> [Nginx unexpectedly returning 304 for content cached from proxy - NGINX - Ruby-Forum](http://www.ruby-forum.com/topic/188902) with nginx 0.7.64. Also the  
> workaround  
> proxy\_set\_header If-None-Match “”;  
> does work properly.
> 
> I think the problem is just one typo in a source code, please check  
> the attached patch.

Just hit the same issue on latest Ubuntu stable package (0.7.62) when  
we introduced proxy\_cache into our QA environment.

The bug actually breaks our sites specacularly depending on the order  
and timing of requests that come into the proxy; everybody can get a  
304 for stylesheets as mentioned by previous posters.

David, why do you say the workaround (proxy\_set\_header If-None-Match  
“”) not work properly? It seems like it should…

I’m trying to figure out if I need to abandon the packaged nginx from  
Ubuntu (an adminsitrative hassle) to apply this patch.  
Igor, is this patch planned for inclusion 0.7.65?

Thanks,

–  
RPM

---

<div class="post-metadata">

**Author:** ![ntk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/48db29/32.png) [@ntk](https://www.ruby-forum.com/u/ntk)\
**Post date:** [January 21, 2010, 10:39am UTC](https://www.ruby-forum.com/t/re-nginx-unexpectedly-returning-304-for-content-cached-from-proxy/180458/3 "2010-01-21T10:39:31Z")

</div>

If using proxy\_set\_header If-None-Match “”;then when the cache file  
expired the cache server will get the file again from the backend server  
even if the file is not changed,it’s not good for a high traffic load  
site.  
Maybe the nginx should see if the cache key exist first:  
if exist then fw the If-None-Match header to backend,if the file has  
been changed, get file from the backend and overwrite the cache file,if  
not changes,reture 304,then remain the cache file.  
if no exist,then get rid of the If-None-Match header to get a new file  
from the backend

Posted at Nginx Forum:

> **[Re: Nginx unexpectedly returning 304 for content cached from proxy](https://forum.nginx.org/read.php?2,2703,43781#msg-43781)**
>
> 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
