Nginx unexpectedly returning 304 for content cached from proxy
uqtdettr
nginx-forum at nginx.us
Mon Sep 21 09:06:48 MSD 2009
I'm getting similar problems with 304 messages being incorrectly returned with nginx 0.8.14:
> 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
instead of:
> 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
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:
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;
}
}
Any ideas on a work-around or further debugging details I should provide?
Thank you,
Tim
Posted at Nginx Forum: http://forum.nginx.org/read.php?2,2703,8049#msg-8049
More information about the nginx
mailing list