Welcome! Log In Create A New Profile

Advanced

Re: Are numbered captures available to the proxy cache key construct?

Maxim Dounin
September 20, 2010 08:20AM
Hello!

On Mon, Sep 20, 2010 at 07:24:30AM -0400, portante wrote:

> Hi Folks,
>
> Can somebody comment on whether proxy_cache_key is supposed to be able
> to handle # captures? I believe the below example shows how I want to
> use it, but I can't get it to work.
>
> Thanks,
>
> -peter
>
>
> [code]
> location ~ ^/api/rest/\d+/(.+)/.+/*$ {
> proxy_cache apiCache;
> proxy_cache_valid 200 7d;
> proxy_cache_use_stale updating;
> proxy_cache_key "$host.$1";
> if ($upstream_http_content_encoding !~* "") { gzip off; }
> proxy_pass http://127.0.0.1:8080$request_uri;
> }
> [/code]

Regexp match in "if" directive will be executed (and will reset
enumerated captures) before proxy module will have cance to grab
$1. Use named captures as available in 0.8.25+ to avoid such
problems.

Additionally, "if" directive in question is useless due to the
following reasons:

- $upstream_* variables are only available after nginx got reply
from upstream, while rewrite directives are executed at rewrite
phase - before we even send request to upstream.

- gzip module is smart enough to don't re-encode replies which
already have content-encoding applied.

Maxim Dounin

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

Are numbered captures available to the proxy cache key construct?

portante September 20, 2010 07:24AM

Re: Are numbered captures available to the proxy cache key construct?

Maxim Dounin September 20, 2010 08:20AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 174
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready