Skip to content

Commit 480de4c

Browse files
committed
now we also allow "0" to indicate false values for srcache_store_skip and srcache_fetch_skip. also added more docs to README.
1 parent 47457b4 commit 480de4c

File tree

4 files changed

+52
-9
lines changed

4 files changed

+52
-9
lines changed

README

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,12 @@ Caveat
113113
Directives
114114
srcache_fetch <method> <uri> <args>?
115115

116-
srcache_fetch_skip
116+
srcache_fetch_skip <flag>
117+
Default: srcache_fetch_skip 0
118+
119+
The <flag> argument supports nginx variables.
120+
When this argument's value is not empty AND not equal to "0",
121+
then the fetching process will be unconditionally skipped.
117122

118123
srcache_store <method> <uri> <args>?
119124

@@ -130,7 +135,24 @@ Directives
130135

131136
When 0 is specified (the default value), there's no limit check at all.
132137

133-
srcache_store_skip
138+
srcache_store_skip <flag>
139+
Default: srcache_store_skip 0
140+
141+
The <flag> argument supports nginx variables.
142+
When this argument's value is not empty AND not
143+
equal to "0", then the storing process will be
144+
unconditionally skipped.
145+
146+
Here's an example using Lua to set $nocache to avoid
147+
storing URIs that contain the string "/tmp":
148+
149+
set_by_lua $nocache '
150+
if string.match(ngx.var.uri, "/tmp") then
151+
return 1
152+
end
153+
return 0';
154+
155+
srcache_store_skip $nocache;
134156

135157
Installation
136158
1. Grab the nginx source code from nginx.net (< http://nginx.net/ >), for

src/ngx_http_srcache_filter_module.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,12 @@ ngx_http_srcache_header_filter(ngx_http_request_t *r)
218218
&& skip.len
219219
&& (skip.len != 1 || skip.data[0] != '0'))
220220
{
221-
dd("bypass by srcache store skip");
221+
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
222+
"srcache_store skipped due to the true value fed into "
223+
"srcache_store_skip: \"%V\"", &skip);
224+
222225
ctx->store_skip = 1;
226+
223227
return ngx_http_next_header_filter(r);
224228
}
225229

@@ -666,9 +670,13 @@ ngx_http_srcache_access_handler(ngx_http_request_t *r)
666670

667671
if (conf->fetch_skip != NULL
668672
&& ngx_http_complex_value(r, conf->fetch_skip, &skip) == NGX_OK
669-
&& skip.len != 0)
673+
&& skip.len
674+
&& (skip.len != 1 || skip.data[0] != '0'))
670675
{
671-
dd("bypass by srcache_fetch_skip");
676+
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
677+
"srcache_fetch skipped due to the true value fed into "
678+
"srcache_fetch_skip: \"%V\"", &skip);
679+
672680
return NGX_DECLINED;
673681
}
674682

util/build.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ if [ ! -s "nginx-$version.tar.gz" ]; then
2323
tar -xzvf nginx-$version.tar.gz || exit 1
2424
fi
2525

26-
#tar -xzvf nginx-$version.tar.gz || exit 1
27-
#cp $root/../no-pool-nginx/nginx-$version-no_pool.patch ./ || exit 1
28-
#patch -p0 < nginx-$version-no_pool.patch || exit 1
26+
tar -xzvf nginx-$version.tar.gz || exit 1
27+
cp $root/../no-pool-nginx/nginx-$version-no_pool.patch ./ || exit 1
28+
patch -p0 < nginx-$version-no_pool.patch || exit 1
2929
#cp ~/work/nginx-$version-valgrind_fix.patch ./ || exit 1
3030
#patch -p0 < nginx-$version-valgrind_fix.patch || exit 1
3131

valgrind.suppress

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,4 +275,17 @@
275275
fun:ngx_single_process_cycle
276276
fun:main
277277
}
278-
278+
{
279+
<insert_a_suppression_name_here>
280+
Memcheck:Leak
281+
fun:malloc
282+
fun:ngx_alloc
283+
fun:ngx_pcalloc
284+
}
285+
{
286+
<insert_a_suppression_name_here>
287+
Memcheck:Leak
288+
fun:malloc
289+
fun:ngx_alloc
290+
fun:ngx_palloc
291+
}

0 commit comments

Comments
 (0)