# Captcha - No Caching?

**URL:** <https://www.ruby-forum.com/t/captcha-no-caching/209516>\
**Category:** NGINX\
**Created:** [July 15, 2011, 2:15pm UTC](https://www.ruby-forum.com/t/captcha-no-caching/209516 "2011-07-15T14:15:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [July 15, 2011, 2:15pm UTC](https://www.ruby-forum.com/t/captcha-no-caching/209516/1 "2011-07-15T14:15:58Z")

</div>

Hello Everybody,

I have a Caching problem with any captcha pictures in nginx.

HTTP-Header: GET /index.php?eID=sr\_freecap\_captcha&id=650

How can I tell nginx, that he will not caching this request, when there  
is the following string:

eID=sr\_freecap\_captcha

Config:

set $captcha\_caching 1;  
if ($arg\_eID ~ ‘sr\_freecap\_captcha’)  
{  
set $captcha\_caching 0;  
}

if ($captcha\_caching = 0)  
{  
break;  
}

What is wrong with this config above?

Regards,

Maik

---

<div class="post-metadata">

**Author:** ![maikungeriok](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ea5d25/32.png) [@maikungeriok](https://www.ruby-forum.com/u/maikungeriok)\
**Post date:** [July 15, 2011, 2:30pm UTC](https://www.ruby-forum.com/t/captcha-no-caching/209516/2 "2011-07-15T14:30:07Z")

</div>

Hello!

On Fri, Jul 15, 2011 at 02:15:58PM +0200, Maik U. wrote:

> Hello Everybody,
> 
> I have a Caching problem with any captcha pictures in nginx.
> 
> HTTP-Header: GET /index.php?eID=sr\_freecap\_captcha&id=650
> 
> How can I tell nginx, that he will not caching this request, when there  
> is the following string:
> 
> eID=sr\_freecap\_captcha

Correct solution is to tell it via headers in response. It’s up  
to backend to know if response may be cached or not.

> ```
> break;
> 
> ```
> 
> }
> 
> What is wrong with this config above?

This config isn’t expected to do anything with cache. If you want  
to disable cache based on particular condition, you have the  
following options:

1. Process such requests in another location block. E.g.

2. Use proxy\_no\_cache and proxy\_cache\_bypass directive. E.g.

Please note that 2nd aproach may have problems in case of more  
"if"s used for other reasons (config as shown above should be ok),  
see [GitHub - nginxinc/nginx-wiki: ARCHIVED -- Source for the now archived NGINX Wiki section of https://www.nginx.com · GitHub](http://wiki.nginx.org/IfIsEvil).

Maxim D.
