Nginx 0.7.64 ignoring Cache-Control headers

Hey guys, I apologise if this is covered in another topic, I have
searched many pages on the forum and not come across this issue.

I’m using nginx v. 0.7.64 with the following: --with-debug
–with-http_stub_status_module --with-http_flv_module
–with-http_ssl_module --with-http_dav_module
–with-http_gzip_static_module --with-mail --with-mail_ssl_module
–with-ipv6

I’ve configured a host to reverse proxy to Apache with proxy_store
enabled:

    location / {
            proxy_pass http://localhost:8080;
            proxy_redirect off;

            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For 

$proxy_add_x_forwarded_for;

            client_max_body_size 10m;
            client_body_buffer_size 128k;

            proxy_connect_timeout 90;
            proxy_send_timeout 90;
            proxy_read_timeout 90;

            proxy_buffer_size 4k;
            proxy_buffers 4 32k;
            proxy_busy_buffers_size 64k;
            proxy_temp_file_write_size 64k;

            if ($request_uri ~ /$) {
                    set $store_extra index.html;
            }

            proxy_store /tmp/nginx/$http_host/${uri}${store_extra};
            proxy_store_access user:rw  group:rw  all:r;
    }

And placed several test PHP files in to the host directory with
different Cache-Control headers

1.php

<? header("Cache-Control: private,max-age=0"); echo "test"; ?>

2.php

<? header("Cache-Control: public,max-age=3600"); echo "test"; ?>

When I access both files with Firefox and inspect their headers using
Live HTTP Headers I can see that the correct Cache-Control headers are
there, yet nginx is ignoring them and caching both files.

Am I missing a module or a patch? I was advised in another post that
this was one of the ways to control which files nginx actually cached
and this seemed like the best approach to it.

Posted at Nginx Forum:

Hello!

On Sat, Feb 06, 2010 at 05:10:53PM -0500, Kura wrote:

Hey guys, I apologise if this is covered in another topic, I
have searched many pages on the forum and not come across this
issue.

I’m using nginx v. 0.7.64 with the following: --with-debug
–with-http_stub_status_module --with-http_flv_module
–with-http_ssl_module --with-http_dav_module
–with-http_gzip_static_module --with-mail
–with-mail_ssl_module --with-ipv6

[…]

<? that this was one of the ways to control which files nginx actually cached and this seemed like the best approach to it.

nginx honors “max-age=” and “no-cache” directives from
Cache-Control header.

But there is a bug in 0.7.64 with parsing Cache-Control with
multiple directives, it was fixed in 0.8.20 and bugfix was merged
into 0.7.65:

*) Bugfix: nginx did not treat a comma as separator in the
   "Cache-Control" backend response header line.

Please upgrade.

Maxim D.

Upgraded to 0.7.65, changed header to: header(“Cache-Control: no-cache,
must-revalidate”);

nginx is still not honouring the header…

Posted at Nginx Forum:

Check the CHANGES file in source, can’t see anything about Cache-Control
headers other than:

*) Bugfix: nginx did not treat a comma as separator in the
   "Cache-Control" backend response header line.

Tried using -

Cache-Control: no-cache
Cache-Control: private,max-age=0
Cache-Control: private

None work, nginx is still ignoring the Cache-Control headers on .0.7.65,
would rather not upgrade to 0.8.* =/

Posted at Nginx Forum:

Hello!

On Sat, Feb 06, 2010 at 05:58:34PM -0500, Kura wrote:

Cache-Control: private

None work, nginx is still ignoring the Cache-Control headers on
.0.7.65, would rather not upgrade to 0.8.* =/

Ah, I missed you are using proxy_store, not proxy_cache. It’s not
cache, it’s unconditional store, and it’s up to you to control
what you store and how do you use or expire it.

Maxim D.