Add files to cache manually

foobug nginx-forum at forum.nginx.org
Thu May 20 18:42:10 UTC 2021


I have nginx setup to proxy file uploads. The file upload streams into
nginx, goes into my upstream, and then the upstream streams it to Amazon S3
(after some basic processing). In addition to proxying the upload, I also
want to proxy the download, with some caching on the nginx side.

It would be ideal if I could add the uploaded file directly to the nginx
cache after it is uploaded, so nginx does not have to re-download it from S3
immediately after it was uploaded there.

One option is to keep a copy of the file on disk (outside of the nginx
cache). Then use something like try_files to read it, and have that response
be cached by nginx. But then I end up with 2 of the files on disk (one in my
try_files directory, and one in the nginx cache). I also need to manually
manage the files stored in my try_files directory (to delete them after they
enter the nginx cache). This is kind of ugly.

If I can reverse engineer the nginx cache file format, is there a way to
tell the nginx cache manager that it exists? Right now, it seems like the
cache manager will disregard any files in the nginx cache that it doesn't
know about.

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,291581,291581#msg-291581



More information about the nginx mailing list