Add files to cache manually

Reinis Rozitis r at
Fri May 21 11:56:55 UTC 2021

> 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.

Is there a reason why you need nginx "cache" instead of just storing the
files statically?
One way would be instead of using the cache just store the files as is (in
the same structure) with proxy_store (there
is even a small configuration example).

The only drawback in this is that you have to manage the cache directory
yourself (delete old files / implement LRU if needed etc), but that's
usually not too hard with `find` and works just fine.


More information about the nginx mailing list