Nginx – disable POST data caching


I noticed that when someone sends big file to Apache website proxied by Nginx, disk usage on Nginx machine goes up. It's especially noticeable when someone uploads file that is big comparing to disk size of Nginx machine. It rises obvious questions – what if someone uploaded lets say 500gb file while Nginx VM has only 10gb drive. It's not that much abstract scenario considering that it's our private cloud that we use for sending VM images (.vmdk or .ova files) which usually have 10+ gigabytes.

I'm already using:

proxy_buffering off;
proxy_no_cache 1;

in http scope. But it doesn't seem to affect uploaded files (only downloaded ones). Is it possible to disable POST caching?

Best Answer

nginx doesn't cache anything by default in it's proxy cache. It even doesn't have it configured. So if you have it configured and if you have configured the caching, you should know how to disable it, and that's not a sarcasm: since you're asking for a way to do this - your disk usage probably grows due to other reasons than stated; not due to caching. Nginx can buffer excessive POST data on the disk, but this gets deleted as soon as the transmission comes to an end.

Another possible scenario - you got a web-server that someone else has configured. Then you should check for proxy_cache <zonename> directives. But I doubt the latter is in effect.

You could easily determine what is consuming the disk by issuing a serie of du -h -d 1 / commands, replacing / on each iteration with more specific path of interest.

Related Topic