POST response caching does not work in nginx POST response caching does not work in nginx nginx nginx

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:

  1. Output Cache-Control: public, max-age=10 header on the server
  2. Add proxy_cache_path config and location config in nginx (examples are given in the question text)
  3. Make sure that proxy_buffering is on for the location on which we want to have caching enabled.