POST response caching does not work in nginx
It turned out that the following directive (which was defined globally) prevented caching from working:
proxy_buffering off;
When I override it under location
config with proxy_buffering on;
, caching starts working.
So, to make caching work with POST requests, we have to do the following:
- Output
Cache-Control: public, max-age=10
header on the server - Add
proxy_cache_path
config andlocation
config in nginx (examples are given in the question text) - Make sure that
proxy_buffering
ison
for the location on which we want to have caching enabled.