I have simple location used for server-generated caches:
location /api/get-hloc {
#add acccess-allow headers
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
#try cached files
root /dev/shm/get-hloc/;
try_files /$arg_hash.hloc /stocks/graphics/get-iis-graphic?$args;
}
What it does? It simply checks if there is a file in memory, that can be served for request and if there is no file, tries the location that actually generates file for future requests and serves it to the client.
It all works as expected, except add_header
directive which is ignored.
Is it possible to addheaders before trying new location in try_files or I should add headers at the endpoint location only?