0

I want to specify no caching for some responses from my (Pylons) upstream server in order to avoid users being able to access cached content after logoff. To do that I'm returning a no-cache header as per the nginx docs. Specifically, this one:

Cache-Control: max-age=0, must-revalidate, no-cache, no-store

Nginx returns a cached response anyway, ignoring my header. Any ideas why?

Thanks, Rick

4 Answers4

1

nginx changelog for 0.7.48 mentions a bugfix:

Bugfix: now nginx takes into account the "X-Accel-Expires", "Expires", and "Cache-Control" header lines in a backend response.

0

Maybe you use proxy_ignore_headers:

proxy_ignore_headers "Cache-Control" "Expires";

Comment or delete this string.

ooshro
  • 11,134
  • 1
  • 32
  • 31
0

Nope, not using that directive at all. Here's the config:

worker_processes  1;

error_log  logs/error.log;
pid        logs/nginx.pid;

events {
  worker_connections  1024;
}

http {
  include       mime.types;
  default_type  application/octet-stream;

  access_log  logs/access.log;

  sendfile        on;

  keepalive_timeout  65;
  tcp_nodelay        on;

  gzip  on;
  gzip_disable "MSIE [1-6]\.(?!.*SV1)";
}
server {
    listen       80;
    server_name  site.com;
    server_name_in_redirect off;
    client_max_body_size 11M;


    location ^~ /members/ {
             proxy_pass http://127.0.0.1:5010;
    }

    location ^~ /login/ {
             rewrite ^ https://$host$request_uri permanent;
    }


    error_page    404  /error/404.html;
    error_page    500 502 503 504  /error/500.html;
}
0

I would use the "private" option for cache control, on the other side nginx doesnt cache unless you specify proxy_cache configuration options, are you sure that the caching is done in nginx ?

Ochoto
  • 1,166
  • 7
  • 12