proxy_ignore_headers doesn't seem to work

Maxim Dounin mdounin at mdounin.ru
Sun Dec 18 11:17:35 UTC 2011


Hello!

On Sat, Dec 17, 2011 at 10:19:29AM -0500, piotr wrote:

> Maxim Dounin Wrote:
> > Try "nginx -t".  If it doesn't help, please post
> > the full config 
> > you're testing with.
> > 
> 
> Hi,
> 
> Maxim, thank you for your response!
> 
> I've checked both servers for config errors before, but without any
> clues.

[...]

> ***** sample headers from upstream server:
> 
> http://otile3.mqcdn.com/tiles/1.0.0/osm/15/5240/12661.jpg
> 
> GET /tiles/1.0.0/osm/15/5240/12661.jpg HTTP/1.1
> Host: otile3.mqcdn.com
> User-Agent: Mozilla/5.0 (Ubuntu; X11; Linux i686; rv:8.0) Gecko/20100101
> Firefox/8.0
> Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
> Accept-Language: en,en-us;q=0.7,pl;q=0.3
> Accept-Encoding: gzip, deflate
> Accept-Charset: ISO-8859-2,utf-8;q=0.7,*;q=0.7
> Connection: keep-alive
> If-Modified-Since: Tue, 13 Dec 2011 06:16:41 GMT
> 
> HTTP/1.1 304 Not Modified
> Content-Type: image/jpeg
> Expires: Fri, 16 Dec 2011 14:16:45 GMT
> Last-Modified: Tue, 13 Dec 2011 06:16:41 GMT
> Cache-Control: max-age=600
> Date: Fri, 16 Dec 2011 14:06:45 GMT
> Connection: keep-alive

Note:
Expires == Date + Cache-Control max-age.

> ***** sample headers from nginx proxy
> http://mpq1.XXX.com/tiles/1.0.0/osm/15/5240/12661.jpg
> 
> GET /tiles/1.0.0/osm/15/5240/12661.jpg HTTP/1.1
> Host: mpq1.XXX.com
> User-Agent: Mozilla/5.0 (Ubuntu; X11; Linux i686; rv:8.0) Gecko/20100101
> Firefox/8.0
> Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
> Accept-Language: en,en-us;q=0.7,pl;q=0.3
> Accept-Encoding: gzip, deflate
> Accept-Charset: ISO-8859-2,utf-8;q=0.7,*;q=0.7
> Connection: keep-alive
> Cookie: bblastvisit=1323941196; bblastactivity=0;
> __qca=P0-811271075-1323941200190;
> __utma=26892847.397077741.1323941200.1323964564.1324035857.4;
> __utmz=26892847.1323941200.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none);
> bbuserid=33280; bbpassword=be7f8ba39107f78fb42020ad76ca953b;
> __utmc=26892847; bbsessionhash=0d7cdd74637b9f503c4f33d7ad1f8394
> 
> HTTP/1.1 200 OK
> Server: nginx/1.0.10
> Date: Fri, 16 Dec 2011 14:08:43 GMT
> Content-Type: image/jpeg
> Connection: keep-alive
> Expires: Wed, 14 Dec 2011 14:59:21 GMT
> Last-Modified: Tue, 13 Dec 2011 06:16:41 GMT
> Cache-Control: max-age=600
> Content-Length: 18419

Note:
Expires < Date + Cache-Control max-age.

The difference is about 2 days, so it looks like 
proxy_ignore_headers works as it should.

I suppose previously you've looked at files cached without 
proxy_ignore_headers in config.  Note that changing config isn't 
enough to get longer cache valid times for already cached 
responses, since validity time is calculated while obtaining 
response from a backend.  A response have to be recached with the 
new settings.

A side note: you may want to hide or change Expires header to 
make sure clients will be able to cache responses.  This may be 
done either with proxy_hide_header or with "expires" directive.

Maxim Dounin



More information about the nginx mailing list