Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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/;

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_in_redirect off;
    client_max_body_size 11M;

    location ^~ /members/ {

    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


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.