Limiting total disk space used by cache + temp files

Michael Corn nginx-forum at forum.nginx.org
Thu May 4 06:50:53 UTC 2017


Hi,

I'm trying to limit the overall disk usage for the cache + any temp files.

I have specified:
                        proxy_cache_path  /tmp/cache max_size=50m 
use_temp_path=off;
                        proxy_max_temp_file_size 1m;

Yet, what I observe is that the temp file will grow to the full size of the
file being retrieved from the upstream, ignoring the value of
proxy_max_temp_file_size, and ignoring the max_size for the cache. Only
after the file is brought over completely does the cache manager kick in and
delete something older from the cache to bring it back in line with the 50mb
limit.

For example, if I had in the cache file1 (20 MB) and file2 (20 MB), and I
receive a request for file3 which is 20 MB, the total size of the /tmp/cache
directory will grow to 60 MB. Only after file3 is received in its entirety
will file1 be deleted bringing the size back down to 40 MB.

I don't mind setting use_temp_path=on, but in that case as well the temp
file grows beyond the proxy_max_temp_file_size.

Any advice?

Michael

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



More information about the nginx mailing list