Old thread: Cache for non-cookie users and fresh for cookie users

António P. P. Almeida appa at perusio.net
Sat Feb 11 00:06:49 UTC 2012


On 10 Fev 2012 17h47 WET, nginxyz at mail.ru wrote:

>
> The default behaviour is not to cache POST method request responses,
> but I turned caching of POST method request responses ON, so I had
> to make sure the cache is bypassed for POST method requests (but
> not for GET or HEAD method requests!). All POST method requests
> are passed on to the backend without checking for a match in the
> cache, but - CONTRARY to the default behavior - all POST method
> request responses are cached.
>
> Without the @post_and_refresh_cache location block and without
> the proxy_cache_bypass directive, nginx would check the cache
> and return the content from the cache (put there by a previous
> GET request response, for example) and would not pass the POST
> method request on to the backend, which is definitely not what
> you want in this case.

If what the OP wanted was to distinguish between cached POST and GET
request responses then just add $request_method to the cache key.

--- appa



More information about the nginx mailing list