Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

share|improve this question

4 Answers 4

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.

share|improve this answer

Maybe you use proxy_ignore_headers:

proxy_ignore_headers "Cache-Control" "Expires";

Comment or delete this string.

share|improve this answer

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;
}
share|improve this answer

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 ?

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.