caching: Expires takes precedence over max-age

hippo nginx-forum at nginx.us
Thu Aug 1 07:59:45 UTC 2013


Hello, I have a trouble with nginx caching pages it shouldn't cache. I have
uwsgi_cache enabled:

uwsgi_cache_path /tmp/cache levels=1:2 keys_zone=django:1m;
location /test {
    uwsgi_pass unix:/tmp/uwsgi.sock;
    uwsgi_cache django;
}

nginx caches responses that have Expires header set in the future, even if
Cache-Control says otherwise:

Expires: Fri, 02 Aug 2013 19:47:42 GMT
Cache-Control: no-cache, must-revalidate, max-age=0

And rfc2616 says:

Note: if a response includes a Cache-Control field with the max-
age directive (see section 14.9.3), that directive overrides the
Expires field.

Happens on nginx 1.2.1 and 1.4.1. If I add "uwsgi_ignore_headers Expires;"
to the nginx conf, the pages don't get cached. Is there something wrong with
my nginx or uwsgi response headers?

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,241443,241443#msg-241443



More information about the nginx mailing list