proxy_cache_use_stale updating

Nguyen Nhat Khang lists at ruby-forum.com
Wed Sep 9 10:38:18 UTC 2015


I've one storage server using nginx, one cache file server using nginx.
The following are my configuration files:
  1. storage_server.conf(ip address 192.168.1.10):
  server {
    listen      80;
    listen [::]:80 ipv6only=on;
    server_name  _;

    location / {
        return 403;
    }
   location ~ ^/cache/ {
        root /var/my_file_storage;
        directio 1m;
        directio_alignment 8k;
        output_buffers  1 1m;
        try_files $request_uri  =404;
    }
   }

  2. cache_server.conf(ip address 192.168.1.2):
  proxy_cache_path /nginx-cache/cache-level1/cache levels=1
keys_zone=CacheLVL1:10m inactive=12h max_size=5G;
server {
    listen       80;
    listen       [::]:80 ipv6only=on;
    server_name  _;

    location / {
        return 403;
    }

    location ~ ^/cache/ {
        proxy_pass              http://192.168.1.10:80$request_uri; #
request_uri is path to file on Storage server.
        proxy_cache            CacheLVL1;
        proxy_cache_key     $request_uri;
        proxy_cache_valid    200 30d;
        proxy_temp_path      /nginx-cache/cache-level1/temp;
        proxy_cache_use_stale updating;
        proxy_max_temp_file_size 0;
        add_header X-Proxy-Cache  $upstream_cache_status;
        proxy_set_header Range $http_range;
        proxy_set_header If-Range $http_if_range;
    }
}
  /etc/nginx/nginx.conf
  ...{
  ...
  log_format upstreamlog '[$time_local] $remote_addr to $upstream_addr
$upstream_cache_status';
  access_log /var/log/nginx/cache.log upstreamlog;
  ...
  }

I've read about proxy_cache_use_stale updating. But I do not understand
how its activities:
 1.
http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_cache_use_stale:
the updating parameter permits using a stale cached response if it is
currently being updated. This allows minimizing the number of accesses
to proxied servers when updating cached data.
 2. https://www.ruby-forum.com/topic/212402#new: "If I understand this
right if I use proxy_cache_use_stale  updating and
If I have 1000 users trying to access  expired cached information. It
will only send one request to backend server to update the cache ?"

I request multiple times and received multiple files in the
/nginx-cache/cache-level1/temp folder 000000xx format. I think I have
the wrong configuration in my configuration file because it works unlike
what I've read. I never saw the $ upstream_cache_status UPDATING in
cache.log.
It is related to X-Accel-Expires "," Expires "," Cache-Control "is not?
Can someone explain to proxy_cache_use_stale updating your help, Thank!

-- 
Posted via http://www.ruby-forum.com/.



More information about the nginx mailing list