使用caching文件mtime作为Last-Modified标题值

nginx 1.10.1我代理外部网站(不在我的控制之下)在本地caching图像。

我的configuration如下:

location ~ /cachedimages/(?<productcode>.*)/(?<size>.*)/image.jpg { resolver 127.0.0.1; proxy_pass https://www.externalsite.example/api/getImage/?productcode=$productcode&size=$size; proxy_cache imgcache; proxy_cache_valid 200 1d; proxy_cache_use_stale error timeout invalid_header updating http_500 http_502 http_503 http_504; expires 1M; access_log off; add_header 'Cache-Control' "public"; add_header Last-Modified $upstream_http_last_modified; add_header X-Proxy-Cache $upstream_cache_status; } 

imgcache定义如下:

 proxy_cache_path /var/cache/nginx/imgcache levels=1:2 keys_zone=imgcache:10m max_size=1g inactive=24h; 

远程服务器不会提供Last-Modified标头:

 curl -X GET -I https://www.externalsite.example/api/getImage/?productcode=abc123&size=128 HTTP/1.1 200 OK Date: Thu, 15 Sep 2016 08:16:07 GMT Server: Apache Transfer-Encoding: chunked Content-Type: image/jpeg 

和我的服务器添加一些头,但不是Last-Modified

 curl -X GET -I https://www.myserver.com/cachedimages/abc123/128/image.jpg HTTP/1.1 200 OK Server: nginx Date: Thu, 15 Sep 2016 08:33:26 GMT Content-Type: image/jpeg Transfer-Encoding: chunked Connection: keep-alive Expires: Sat, 15 Oct 2016 08:33:26 GMT Cache-Control: max-age=2592000 Cache-Control: public X-Proxy-Cache: HIT 

我如何强制nginx读取caching(和命中)文件的mtime并将其作为Last-Modified标头值?