# How to check that $request\_body has some string and use it like a caching key?

**URL:** <https://www.ruby-forum.com/t/how-to-check-that-request-body-has-some-string-and-use-it-like-a-caching-key/211892>\
**Category:** NGINX\
**Created:** [September 16, 2011, 5:09am UTC](https://www.ruby-forum.com/t/how-to-check-that-request-body-has-some-string-and-use-it-like-a-caching-key/211892 "2011-09-16T05:09:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [September 16, 2011, 5:09am UTC](https://www.ruby-forum.com/t/how-to-check-that-request-body-has-some-string-and-use-it-like-a-caching-key/211892/1 "2011-09-16T05:09:45Z")

</div>

Hi everybody,

I have the following situation:

Incoming request with method POST has binary body. I would like to  
extract piece(s) from the payload to use it like a caching key.

Something like:

if ( $request\_body ~\* (action.\*) ) {  
set $key $1;  
}  
…  
proxy\_cache\_key $uri|$key

Unfortunately it does not work for me even if I specified (like Igor  
advised):

client\_max\_body\_size 1k;

I also tried client\_body\_buffer\_size 1k; but it did not help either.

In the error.log with debug on I can see that $request\_body has value,  
but it never matches my condition, so $key is always empty.

Just in case I’m repeating, that request\_body is binary. It has 0x00 as  
well as everything else. It is AMF data.

Any advices?

Thanks  
—\>\>\> qzpmwo \<\<\<—

Posted at Nginx Forum:

> **[How to check that $request\_body has some string and use it like a caching key?](https://forum.nginx.org/read.php?2,215279,215279#msg-215279)**
>
> Hi everybody, I have the following situation: Incoming request with method POST has binary body. I would like to extract piece(s) from the payload to use it like a caching key. Something like: if ( $request\_body ~\* (action.\*) ) {
