Proxy_cache_key with variables

I’ve just created a configuration composed of two servers.
Both just forwards traffic from different ports (and protocols) to
different
servers, and keep responses in cache. It works nice.

For both servers “GET /” request is sent, in the response there is
proper
resource. Thus (to distinguish responses in the cache) I added for both
cache_key:

proxy_cache_key “$upstream_addr*$request”;

But it doesn’t work. I found that upstream states are not available and
thus
“proxied” address is not known when cache key is computed. And “proxied”
address is computed only when additional stream must be used…

Is there any way to get proper key? Or any other way to keep all copies
in
the cache?

I plan to add “load balancing” module, which would be able to forward
request on (multiple) source addresses to multiple proxied addresses,
with
caching… Will it work properly?

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

Hi,

proxy_cache_key “$upstream_addr*$request”;
I am not sure that you are using the correct format for proxy_cache_key
directive.
my I know what is the wildcard char “*” doing out there, between
$upstream_addr and $request?

refer to nginx directive example:
proxy_cache_key “$host$request_uri $cookie_user”;
or by default is
proxy_cache_key $scheme$proxy_host$uri$is_args$args;

I plan to add “load balancing” module, which would be able to forward
request on (multiple) source addresses to multiple proxied addresses,
with
caching… Will it work properly?
if your nginx is acting as load balancer, I guess better add load
balancing
module.

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,260086,260088#msg-260088

proxy_cache_key "$upstream_addr*$request”;
At the time when this expression is evaluated, $upstream_addr is still
unknown
since no upstream connection is made. Obviously, if a key is found in
cache,
there will be no upstream connection at all. So it’s not a good idea to
use
$upstream_addr in key definition. Instead, you can use the parts of
request
which define the upstream address.

caching… Will it work properly?

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


nginx mailing list
[email protected]
http://mailman.nginx.org/mailman/listinfo/nginx


Roman A.

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

| Privacy Policy | Terms of Service | Remote Ruby Jobs