Welcome! Log In Create A New Profile

Advanced

Re: Nginx unexpectedly returning 304 for content cached from proxy

September 21, 2009 01:06AM
I'm getting similar problems with 304 messages being incorrectly returned with nginx 0.8.14:

[code]
> HEAD /css/rich.css HTTP/1.1
> User-Agent: curl/7.16.3 (i686-pc-cygwin) libcurl/7.16.3 OpenSSL/0.9.8i zlib/1.2.3 libssh2/0.15-CVS
> Host: prod-login.uqconnect.net
> Accept: */*
>
< HTTP/1.1 304 Not Modified
< Server: nginx/0.8.14
< Date: Mon, 21 Sep 2009 04:52:33 GMT
< Connection: keep-alive
< ETag: "189ad-1b68-4727c27516700"
< Expires: Mon, 21 Sep 2009 04:52:34 GMT
< Cache-Control: max-age=5
[/code]

instead of:
[code]
> HEAD /css/rich.css HTTP/1.1
> User-Agent: curl/7.16.3 (i686-pc-cygwin) libcurl/7.16.3 OpenSSL/0.9.8i zlib/1.2.3 libssh2/0.15-CVS
> Host: prod-login.uqconnect.net
> Accept: */*
>
< HTTP/1.1 200 OK
< Server: nginx/0.8.14
< Date: Mon, 21 Sep 2009 04:52:32 GMT
< Content-Type: text/css
< Connection: keep-alive
< Last-Modified: Tue, 01 Sep 2009 03:57:45 GMT
< ETag: "20c55-1b68-4727c2723a040"
< Content-Length: 7016
< Cache-Control: max-age=5
< Expires: Mon, 21 Sep 2009 04:52:33 GMT
< Accept-Ranges: bytes
[/code]

This only happens occasionally. Certainly less than 10% of requests. Unfortunately, failing to load CSS is rather spectacular...

The relevant portion of my config is:
[code]
gzip on;
gzip_proxied any;
# Need Vary on encoding though, otherwise caches may get confused
gzip_vary on;

error_log /var/log/nginx/error.log info;

proxy_temp_path /var/tmp/nginx/tmp;
# Should not be used, but useful for ensuring "cache" dir is created
proxy_cache_path /var/tmp/nginx/cache levels=1:2 keys_zone=core:1m;
# Actual caches start here
proxy_cache_path /var/tmp/nginx/cache/itmp-prod levels=1:2 keys_zone=itmp-prod:1m;
proxy_cache_path /var/tmp/nginx/cache/itmp-test levels=1:2 keys_zone=itmp-test:1m;

proxy_cache_valid 200 302 5m;
proxy_cache_valid 301 1h;
proxy_cache_valid 404 30s;

upstream apache {
server apache.localhost:8080;
server itmp1-gpn.soe.uq.edu.au:8080 backup;
server itmp1-prentice.soe.uq.edu.au:8080 backup;
server itmp2-prentice.soe.uq.edu.au:8080 backup;
}

server {
listen 80;
server_name prod-login.uqconnect.net;

proxy_cache itmp-prod;

location / {
# Proxy to apache backends
proxy_pass http://apache;
# Set header to be what we requested
proxy_set_header Host $host;
# Need this for snooping with tcpdump (turns off upstream compression)
proxy_set_header Accept-Encoding "";
# Set real IP header (needed for portal client IP detection)
proxy_set_header X-Real-IP $remote_addr;
}

}

server {
listen 80;
server_name test-login.uqconnect.net;
server_name dev-login.uqconnect.net;

proxy_cache itmp-test;

location / {
# Proxy to apache backends
proxy_pass http://apache;
# Set header to be what we requested
proxy_set_header Host $host;
# Need this for snooping with tcpdump (turns off upstream compression)
proxy_set_header Accept-Encoding "";
# Set real IP header (needed for portal client IP detection)
proxy_set_header X-Real-IP $remote_addr;
}

}
[/code]

Any ideas on a work-around or further debugging details I should provide?

Thank you,

Tim
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: 281
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready