Answer the question
In order to leave comments, you need to log in
How to emit static or generate stats with nginx?
There is a certain static resource, storage... static.site.com
It contains, as it were, an "eternal cache" of some dynamic files.
For simplicity, in the application, the link immediately goes to the address static.site.com
But if the file was never requested there, it is not, and we must generate it. server static knows nothing about scripts and has no access to php.
I implemented this quite standard solution:
if (!-e $request_filename) {
rewrite ^/dir/file(.*)_(.*).ext https://api.site.com/generate?a$1&b=$2 break;
}
Answer the question
In order to leave comments, you need to log in
It is not at all clear how the file should appear on the nginx server?
The variant with try_files and a redirect in the absence of a file does not go to another resource and that's it. It won't show up locally.
https://www.nginx.com/blog/nginx-caching-guide/ You need to turn on response caching on the nginx side.
if (!-e $request_filename) {
rewrite ...
}
Try like this although not very strong in nginx:
location ~ ^/dir/file(.*)_(.*).ext$ {
try_files $uri https://api.site.com/generate?a$1&b=$2;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question