Caching issues with nginx as reverse-proxy

Hi,
I am using nginx as a reverse proxy and using the proxy-cache, I use the
request body as a cache key as shown below.

location ^~ /mycachepath {
    proxy_pass                http://upstreamservers;
    proxy_buffers             8 32K;
    proxy_buffer_size         64K;
    proxy_cache               proxy-cache;
    proxy_cache_key 

“$scheme$host$request_uri|$request_body”;
proxy_cache_valid 200 1m;
proxy_cache_methods POST GET;
proxy_ignore_headers Cache-Control;
add_header X-Cache-Status $upstream_cache_status;
}

However, I observe that smaller request bodies the cache works perfectly
but
if the request body gets too big then it will actually always return
the
cached version. Does anyone have any idea what’s going on and if someone
also has come across a similar issue ? There is nothing in the logs
except
for this statement - “[warn] 29768#0: *2329 a client request body is
buffered to a temporary file /var/cache/nginx/client_temp/0000000009,”
for a
given request.
Any help is much appreciated.

Thanks!

Posted at Nginx Forum:
https://forum.nginx.org/read.php?2,267961,267961#msg-267961

On Wed, Jun 29, 2016 at 09:00:02PM -0400, blue.outrigger wrote:

Hi there,

I am using nginx as a reverse proxy and using the proxy-cache, I use the
request body as a cache key as shown below.

    proxy_cache_key           "$scheme$host$request_uri|$request_body";

http://nginx.org/r/$request_body

If the request body was not read to a memory buffer, this variable is
presumably empty (and therefore: the same for all requests).

However, I observe that smaller request bodies the cache works perfectly but
if the request body gets too big then it will actually always return the
cached version. Does anyone have any idea what’s going on and if someone
also has come across a similar issue ?

Set your client_body_buffer_size big enough that it will hold the entire
request, if you want to cache POSTs this way.

f

Francis D. [email protected]

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service