If I make a request to a Nginx-proxy server configured to cache an upstream I get the following response headers:
{'content-length': '13200000', 'x-cache-status': 'MISS', 'server': 'nginx/1.9.9', 'connection': 'keep-alive', 'cache-control': 'max-age=45', 'date': 'Fri, 27 Jan 2017 10:57:55 GMT'}
a couple of seconds later I do the same request again, I get the following headers:
{'content-length': '13200000', 'x-cache-status': 'HIT', 'server': 'nginx/1.9.9', 'connection': 'keep-alive', 'cache-control': 'max-age=45', 'date': 'Fri, 27 Jan 2017 10:58:18 GMT'}
The upstream-server specifies the max-age header to 45 seconds, shouldn't the second response header have an updated max-age header? That is max-age=45-(time between the requests)?
Edit
An example config reproducing the behaviour:
http {
include mime.types;
default_type application/octet-stream;
upstream backend {
server localhost:8080;
}
proxy_cache_path /etc/nginx/wwwroot/cache levels=1:2 keys_zone=my_cache:10m max_size=10g inactive=60m use_temp_path=off;
server {
listen 80;
location / {
proxy_pass http://backend;
proxy_cache my_cache;
add_header X-Cache-Status $upstream_cache_status;
}
}
server {
listen 8080;
root /etc/nginx/wwwroot;
expires 60s;
}
}
Result:
root@ubuntu:/home/parallels# curl -I localhost/testfile.txt
HTTP/1.1 200 OK
Server: nginx/1.10.0 (Ubuntu)
Date: Sat, 28 Jan 2017 19:08:45 GMT
Content-Type: text/plain
Content-Length: 12
Connection: keep-alive
Last-Modified: Fri, 27 Jan 2017 14:45:39 GMT
ETag: "588b5d13-c"
Expires: Sat, 28 Jan 2017 19:09:45 GMT
Cache-Control: max-age=60
X-Cache-Status: MISS
Accept-Ranges: bytes
root@ubuntu:/home/parallels# curl -I localhost/testfile.txt
HTTP/1.1 200 OK
Server: nginx/1.10.0 (Ubuntu)
Date: Sat, 28 Jan 2017 19:08:48 GMT
Content-Type: text/plain
Content-Length: 12
Connection: keep-alive
Last-Modified: Fri, 27 Jan 2017 14:45:39 GMT
ETag: "588b5d13-c"
Expires: Sat, 28 Jan 2017 19:09:45 GMT
Cache-Control: max-age=60
X-Cache-Status: HIT
Accept-Ranges: bytes