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
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:
-
Process such requests in another location block. E.g.
location = /index.php {
error_page 418 = @nocache;
if ($arg_eID = 'sr_freecap_captcha') {
return 418;
}
proxy_pass ...
proxy_cache ...
}
location @nocache {
# … no proxy_cache here
proxy_passs …
}
-
Use proxy_no_cache and proxy_cache_bypass directive. E.g.
location = /index.php {
set $nocache 0;
if ($arg_eID = ‘sr_freecap_captcha’) {
set $nocache 1;
}
proxy_pass ...
proxy_cache ...
proxy_cache_bypass $nocache;
proxy_no_cache $nocache;
}
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 If is Evil… when used in location context | NGINX.
Maxim D.