This is my nginx proxy_cache config:
proxy_cache cache_one;
location ~ \.(jpg|png|gif) {
proxy_cache_valid 1d;
}
It's worked but I never know the images expiration time in any way
I wanna add a header for expiration time like this:
location ~ \.(jpg|png|gif) {
proxy_cache_valid 1d;
add_header expires $proxy_cache_expires;
}
Is this possible? how can I get $proxy_cache_expires
?
All available nginx variable from HTTP Proxy Module was listed in this page and all nginx variable was listed in this page. Currently, nginx only expose several variables:
$proxy_add_x_forwarded_for
,$proxy_host
and$proxy_port
.Of course you can achieve it by writing LUA/perl script to inspect the cache file. To give you an idea, here the bash script from António P. P. Almeida a.k.a perusio that can be used to inspect nginx proxy properties, such as expiration time.