I am using an Nginx proxy as a front-end to a web application that tends to get identical duplicate requests milliseconds apart, causing duplicate items in my database.
I thought I might be able to fix this by letting Nginx cache content for 1s, so that duplicate requests would not hit my app at all
I configured it with
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=prevent_duplicates:10m max_size=1g inactive=1s use_temp_path=off;
And then added
proxy_cache prevent_duplicates; to my root location section, where I have proxy_pass
But my application gets hit on all requests anyway - is it a timing thing? Multiple threads all starting at once for each request all thinking they are first?