comparison src/http/modules/ngx_http_uwsgi_module.c @ 5441:43ccaf8e8728

Upstream: cache revalidation with conditional requests. The following new directives are introduced: proxy_cache_revalidate, fastcgi_cache_revalidate, scgi_cache_revalidate, uwsgi_cache_revalidate. Default is off. When set to on, they enable cache revalidation using conditional requests with If-Modified-Since for expired cache items. As of now, no attempts are made to merge headers given in a 304 response during cache revalidation with headers previously stored in a cache item. Headers in a 304 response are only used to calculate new validity time of a cache item.
author Maxim Dounin <mdounin@mdounin.ru>
date Mon, 18 Nov 2013 20:48:22 +0400
parents 1a070e89b97a
children e68af4e3396f
comparison
equal deleted inserted replaced
5440:cbb9a6c7493c 5441:43ccaf8e8728
285 { ngx_string("uwsgi_cache_lock_timeout"), 285 { ngx_string("uwsgi_cache_lock_timeout"),
286 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, 286 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
287 ngx_conf_set_msec_slot, 287 ngx_conf_set_msec_slot,
288 NGX_HTTP_LOC_CONF_OFFSET, 288 NGX_HTTP_LOC_CONF_OFFSET,
289 offsetof(ngx_http_uwsgi_loc_conf_t, upstream.cache_lock_timeout), 289 offsetof(ngx_http_uwsgi_loc_conf_t, upstream.cache_lock_timeout),
290 NULL },
291
292 { ngx_string("uwsgi_cache_revalidate"),
293 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
294 ngx_conf_set_flag_slot,
295 NGX_HTTP_LOC_CONF_OFFSET,
296 offsetof(ngx_http_uwsgi_loc_conf_t, upstream.cache_revalidate),
290 NULL }, 297 NULL },
291 298
292 #endif 299 #endif
293 300
294 { ngx_string("uwsgi_temp_path"), 301 { ngx_string("uwsgi_temp_path"),
400 407
401 408
402 #if (NGX_HTTP_CACHE) 409 #if (NGX_HTTP_CACHE)
403 410
404 static ngx_keyval_t ngx_http_uwsgi_cache_headers[] = { 411 static ngx_keyval_t ngx_http_uwsgi_cache_headers[] = {
405 { ngx_string("HTTP_IF_MODIFIED_SINCE"), ngx_string("") }, 412 { ngx_string("HTTP_IF_MODIFIED_SINCE"),
413 ngx_string("$upstream_cache_last_modified") },
406 { ngx_string("HTTP_IF_UNMODIFIED_SINCE"), ngx_string("") }, 414 { ngx_string("HTTP_IF_UNMODIFIED_SINCE"), ngx_string("") },
407 { ngx_string("HTTP_IF_NONE_MATCH"), ngx_string("") }, 415 { ngx_string("HTTP_IF_NONE_MATCH"), ngx_string("") },
408 { ngx_string("HTTP_IF_MATCH"), ngx_string("") }, 416 { ngx_string("HTTP_IF_MATCH"), ngx_string("") },
409 { ngx_string("HTTP_RANGE"), ngx_string("") }, 417 { ngx_string("HTTP_RANGE"), ngx_string("") },
410 { ngx_string("HTTP_IF_RANGE"), ngx_string("") }, 418 { ngx_string("HTTP_IF_RANGE"), ngx_string("") },
1128 conf->upstream.cache_bypass = NGX_CONF_UNSET_PTR; 1136 conf->upstream.cache_bypass = NGX_CONF_UNSET_PTR;
1129 conf->upstream.no_cache = NGX_CONF_UNSET_PTR; 1137 conf->upstream.no_cache = NGX_CONF_UNSET_PTR;
1130 conf->upstream.cache_valid = NGX_CONF_UNSET_PTR; 1138 conf->upstream.cache_valid = NGX_CONF_UNSET_PTR;
1131 conf->upstream.cache_lock = NGX_CONF_UNSET; 1139 conf->upstream.cache_lock = NGX_CONF_UNSET;
1132 conf->upstream.cache_lock_timeout = NGX_CONF_UNSET_MSEC; 1140 conf->upstream.cache_lock_timeout = NGX_CONF_UNSET_MSEC;
1141 conf->upstream.cache_revalidate = NGX_CONF_UNSET;
1133 #endif 1142 #endif
1134 1143
1135 conf->upstream.hide_headers = NGX_CONF_UNSET_PTR; 1144 conf->upstream.hide_headers = NGX_CONF_UNSET_PTR;
1136 conf->upstream.pass_headers = NGX_CONF_UNSET_PTR; 1145 conf->upstream.pass_headers = NGX_CONF_UNSET_PTR;
1137 1146
1367 ngx_conf_merge_value(conf->upstream.cache_lock, 1376 ngx_conf_merge_value(conf->upstream.cache_lock,
1368 prev->upstream.cache_lock, 0); 1377 prev->upstream.cache_lock, 0);
1369 1378
1370 ngx_conf_merge_msec_value(conf->upstream.cache_lock_timeout, 1379 ngx_conf_merge_msec_value(conf->upstream.cache_lock_timeout,
1371 prev->upstream.cache_lock_timeout, 5000); 1380 prev->upstream.cache_lock_timeout, 5000);
1381
1382 ngx_conf_merge_value(conf->upstream.cache_revalidate,
1383 prev->upstream.cache_revalidate, 0);
1372 1384
1373 #endif 1385 #endif
1374 1386
1375 ngx_conf_merge_value(conf->upstream.pass_request_headers, 1387 ngx_conf_merge_value(conf->upstream.pass_request_headers,
1376 prev->upstream.pass_request_headers, 1); 1388 prev->upstream.pass_request_headers, 1);