Hi,
My model consists of 2 server:
1. Cache server: using nginx it function caching file when Storage server respond.
2. Storage server: using nginxit function storage files.
Here are my 2 configuration files:
1.Cache server config(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.3: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;
}
}
2. Storage server config(ip address 192.168.1.3):
server {
listen 80;
listen [::]:80 ipv6only=on;
server_name _;
location / {
return 403;
}
location ~ ^/cache/ {
root /var/mystorage;
directio 1m;
directio_alignment 8k;
output_buffers 1 1m;
try_files $request_uri =404;
}
}
When I request to cache server with cmd "curl -I http://192.168.1.2/cache/path/to/file" , I received one response has X-Proxy-Cache are MISS, then I checked in directory / a / a, I saw one of the form tmp file 0000001 (this is the file that I had sent in $reuqest_uri). Next I sent one request and I also received one response has X-Proxy-Cache is MISS and in the cache / nginx-cache / cache-level1 / temp / cache file additional 0000002. This is also true with the next request until the file has on / nginx-cache / cache-level1 / cache. I+ts activity is not the same with what I've read on http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_cache_use_stale it said was "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". I also refer http://nginx.org/en/docs/http/ngx_http_upstream_module.html
" $upstream_cache_status
-
keeps the status of accessing a response cache (0.8.3).
The status can be either “
MISS
”,
“BYPASS
”, “EXPIRED
”,
“STALE
”, “UPDATING
”,
“REVALIDATED
”, or “HIT
” "
- So when its status will be "UPDATING" Is there added to the cache server configuration file
-
upstream storage {
- server 192.168.1.3:80;
- server 192.168.1.4:80;
- }
This is true with proxy_next_upstream.
Can you help me explain this problem, thank all