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

Max nginxyz at mail.ru
Sat Feb 11 18:12:13 UTC 2012




11 февраля 2012, 02:25 от Nginx User <nginx at nginxuser.net>:
> On 10 February 2012 20:47, Max <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.
> 
> Your config would do what the OP wanted but it would be nicer, I
> think, if the POST request simply invalidated the existing cached
> content and then for the content to be cached only if and when there
> is a GET request for that item. I.E., for the cache validity to start
> when there is a request to view the item.
> Also avoids using $uri as key which can lead to cache pollution with
> frontend controllers etc.
> 
> An internal call to a proxy_purge location could do this ... maybe as
> a post_action. There will be no need for the proxy_bypass
> 
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
> 


More information about the nginx mailing list