Welcome! Log In Create A New Profile

Advanced

Re: Add support for 'nocache' flag to map directive

December 06, 2016 02:14PM
On Sat, Dec 03, 2016 at 09:06:16PM +0000, Eran Kornblau wrote:
> As I got no objections... :) patch attached

There was a similar patch circulating locally circa 2013.
I've updated it today. Please give it a try.

# HG changeset patch
# User Ruslan Ermilov <ru@nginx.com>
# Date 1481040301 -10800
# Tue Dec 06 19:05:01 2016 +0300
# Node ID a68b9457f36bc0f4bfdf44722e966e790c7fd7f0
# Parent b5ba6cf04d0aa69260f58d5416532c3edc7feb56
Map: simplified "map" block parser.

No functional changes.

diff --git a/src/http/modules/ngx_http_map_module.c b/src/http/modules/ngx_http_map_module.c
--- a/src/http/modules/ngx_http_map_module.c
+++ b/src/http/modules/ngx_http_map_module.c
@@ -393,8 +393,9 @@ ngx_http_map(ngx_conf_t *cf, ngx_command
{
ctx->hostnames = 1;
return NGX_CONF_OK;
+ }

- } else if (cf->args->nelts != 2) {
+ if (cf->args->nelts != 2) {
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
"invalid number of the map parameters");
return NGX_CONF_ERROR;
diff --git a/src/stream/ngx_stream_map_module.c b/src/stream/ngx_stream_map_module.c
--- a/src/stream/ngx_stream_map_module.c
+++ b/src/stream/ngx_stream_map_module.c
@@ -392,8 +392,9 @@ ngx_stream_map(ngx_conf_t *cf, ngx_comma
{
ctx->hostnames = 1;
return NGX_CONF_OK;
+ }

- } else if (cf->args->nelts != 2) {
+ if (cf->args->nelts != 2) {
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
"invalid number of the map parameters");
return NGX_CONF_ERROR;
# HG changeset patch
# User Ruslan Ermilov <ru@nginx.com>
# Date 1481040307 -10800
# Tue Dec 06 19:05:07 2016 +0300
# Node ID 414e7061c1b6fa89003e1c5600921cb48d6d977f
# Parent a68b9457f36bc0f4bfdf44722e966e790c7fd7f0
Map: the "volatile" parameter.

diff --git a/src/http/modules/ngx_http_map_module.c b/src/http/modules/ngx_http_map_module.c
--- a/src/http/modules/ngx_http_map_module.c
+++ b/src/http/modules/ngx_http_map_module.c
@@ -26,7 +26,8 @@ typedef struct {

ngx_http_variable_value_t *default_value;
ngx_conf_t *cf;
- ngx_uint_t hostnames; /* unsigned hostnames:1 */
+ unsigned hostnames:1;
+ unsigned no_cacheable:1;
} ngx_http_map_conf_ctx_t;


@@ -265,6 +266,7 @@ ngx_http_map_block(ngx_conf_t *cf, ngx_c
ctx.default_value = NULL;
ctx.cf = &save;
ctx.hostnames = 0;
+ ctx.no_cacheable = 0;

save = *cf;
cf->pool = pool;
@@ -281,6 +283,10 @@ ngx_http_map_block(ngx_conf_t *cf, ngx_c
return rv;
}

+ if (ctx.no_cacheable) {
+ var->flags |= NGX_HTTP_VAR_NOCACHEABLE;
+ }
+
map->default_value = ctx.default_value ? ctx.default_value:
&ngx_http_variable_null_value;

@@ -395,6 +401,13 @@ ngx_http_map(ngx_conf_t *cf, ngx_command
return NGX_CONF_OK;
}

+ if (cf->args->nelts == 1
+ && ngx_strcmp(value[0].data, "volatile") == 0)
+ {
+ ctx->no_cacheable = 1;
+ return NGX_CONF_OK;
+ }
+
if (cf->args->nelts != 2) {
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
"invalid number of the map parameters");
diff --git a/src/stream/ngx_stream_map_module.c b/src/stream/ngx_stream_map_module.c
--- a/src/stream/ngx_stream_map_module.c
+++ b/src/stream/ngx_stream_map_module.c
@@ -26,7 +26,8 @@ typedef struct {

ngx_stream_variable_value_t *default_value;
ngx_conf_t *cf;
- ngx_uint_t hostnames; /* unsigned hostnames:1 */
+ unsigned hostnames:1;
+ unsigned no_cacheable:1;
} ngx_stream_map_conf_ctx_t;


@@ -264,6 +265,7 @@ ngx_stream_map_block(ngx_conf_t *cf, ngx
ctx.default_value = NULL;
ctx.cf = &save;
ctx.hostnames = 0;
+ ctx.no_cacheable = 0;

save = *cf;
cf->pool = pool;
@@ -280,6 +282,10 @@ ngx_stream_map_block(ngx_conf_t *cf, ngx
return rv;
}

+ if (ctx.no_cacheable) {
+ var->flags |= NGX_STREAM_VAR_NOCACHEABLE;
+ }
+
map->default_value = ctx.default_value ? ctx.default_value:
&ngx_stream_variable_null_value;

@@ -394,6 +400,13 @@ ngx_stream_map(ngx_conf_t *cf, ngx_comma
return NGX_CONF_OK;
}

+ if (cf->args->nelts == 1
+ && ngx_strcmp(value[0].data, "volatile") == 0)
+ {
+ ctx->no_cacheable = 1;
+ return NGX_CONF_OK;
+ }
+
if (cf->args->nelts != 2) {
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
"invalid number of the map parameters");
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

Add support for 'nocache' flag to map directive

erankor 451 November 28, 2016 06:00AM

Re: Add support for 'nocache' flag to map directive

Sorin Manole 215 November 29, 2016 12:20AM

RE: Add support for 'nocache' flag to map directive

erankor 278 November 29, 2016 03:08AM

RE: Add support for 'nocache' flag to map directive Attachments

erankor 305 December 03, 2016 04:08PM

Re: Add support for 'nocache' flag to map directive

ru@nginx.com 308 December 06, 2016 02:14PM

RE: Add support for 'nocache' flag to map directive

erankor 227 December 06, 2016 02:44PM

Re: Add support for 'nocache' flag to map directive

ru@nginx.com 168 December 07, 2016 04:22AM

RE: Add support for 'nocache' flag to map directive

erankor 296 December 07, 2016 04:24AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 77
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready