I use nginx as a reverse proxy, and I would like it to cache POST requests. My backend server is configured correctly to return the appropriate cache control headers for POST requests. In nginx, I configured:
proxy_cache_methods POST; proxy_cache_key "$request_method$request_uri$request_body";
This is great for small HTTP POST requests. However, I began to notice that for large requests (for example, to download files) it seems that $request_body ignored in proxy_cache_key . When a form containing a file upload is submitted twice with completely different data, nginx will return a cached result.
What could be the reason for this? How to configure nginx to use $request_body (or the $request_body hash) in proxy_cache_key even for large POST requests?
Jeroen
source share