Nginx cache behavior for large files and disk full

Viewed 1000

Let's assume that Nginx is configured as a reverse proxy to serve very large files from a storage server. The cache is configured to cache everything with no limits (no max-size) for demo purpose. The server on which nginx is installed has 50 GB of disk space. I was wondering how nginx behaves in these situations:

  1. In case "max-size" is not specified, I understand that nginx can use all the available disk space. But when the disk is full, what is the behavior? It removes the oldest cache?

  2. If thousands of files are cached and a 50 GB file needs to be cached. Nginx will then clean the cache of those thousands of files to make room for one big file?

  3. Nginx receives a request for a 60 GB file. According to the configuration, it must cache it for future requests. But the disk is only 50 GB. Does it start caching the 50 GB file knowing that it will not be able to succeed? Or does it understand that this is not possible and just passes the request without caching.

Thank you

1 Answers

I can answer the first two

  1. Yes, following LRU, but you need min_free specified proxy_cache_path. See proxy_cache_path

When the size is exceeded or there is not enough free space, it removes the least recently used data.

  1. Per 1, yes.

Hope it helps, and I hope someone else can enlighten us with 3rd question.

Related