comparison src/http/modules/ngx_http_fastcgi_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 8c827bb1b2b6
children e68af4e3396f
comparison
equal deleted inserted replaced
5440:cbb9a6c7493c 5441:43ccaf8e8728
403 ngx_conf_set_msec_slot, 403 ngx_conf_set_msec_slot,
404 NGX_HTTP_LOC_CONF_OFFSET, 404 NGX_HTTP_LOC_CONF_OFFSET,
405 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.cache_lock_timeout), 405 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.cache_lock_timeout),
406 NULL }, 406 NULL },
407 407
408 { ngx_string("fastcgi_cache_revalidate"),
409 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
410 ngx_conf_set_flag_slot,
411 NGX_HTTP_LOC_CONF_OFFSET,
412 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.cache_revalidate),
413 NULL },
414
408 #endif 415 #endif
409 416
410 { ngx_string("fastcgi_temp_path"), 417 { ngx_string("fastcgi_temp_path"),
411 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1234, 418 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1234,
412 ngx_conf_set_path_slot, 419 ngx_conf_set_path_slot,
561 568
562 569
563 #if (NGX_HTTP_CACHE) 570 #if (NGX_HTTP_CACHE)
564 571
565 static ngx_keyval_t ngx_http_fastcgi_cache_headers[] = { 572 static ngx_keyval_t ngx_http_fastcgi_cache_headers[] = {
566 { ngx_string("HTTP_IF_MODIFIED_SINCE"), ngx_string("") }, 573 { ngx_string("HTTP_IF_MODIFIED_SINCE"),
574 ngx_string("$upstream_cache_last_modified") },
567 { ngx_string("HTTP_IF_UNMODIFIED_SINCE"), ngx_string("") }, 575 { ngx_string("HTTP_IF_UNMODIFIED_SINCE"), ngx_string("") },
568 { ngx_string("HTTP_IF_NONE_MATCH"), ngx_string("") }, 576 { ngx_string("HTTP_IF_NONE_MATCH"), ngx_string("") },
569 { ngx_string("HTTP_IF_MATCH"), ngx_string("") }, 577 { ngx_string("HTTP_IF_MATCH"), ngx_string("") },
570 { ngx_string("HTTP_RANGE"), ngx_string("") }, 578 { ngx_string("HTTP_RANGE"), ngx_string("") },
571 { ngx_string("HTTP_IF_RANGE"), ngx_string("") }, 579 { ngx_string("HTTP_IF_RANGE"), ngx_string("") },
2334 conf->upstream.cache_bypass = NGX_CONF_UNSET_PTR; 2342 conf->upstream.cache_bypass = NGX_CONF_UNSET_PTR;
2335 conf->upstream.no_cache = NGX_CONF_UNSET_PTR; 2343 conf->upstream.no_cache = NGX_CONF_UNSET_PTR;
2336 conf->upstream.cache_valid = NGX_CONF_UNSET_PTR; 2344 conf->upstream.cache_valid = NGX_CONF_UNSET_PTR;
2337 conf->upstream.cache_lock = NGX_CONF_UNSET; 2345 conf->upstream.cache_lock = NGX_CONF_UNSET;
2338 conf->upstream.cache_lock_timeout = NGX_CONF_UNSET_MSEC; 2346 conf->upstream.cache_lock_timeout = NGX_CONF_UNSET_MSEC;
2347 conf->upstream.cache_revalidate = NGX_CONF_UNSET;
2339 #endif 2348 #endif
2340 2349
2341 conf->upstream.hide_headers = NGX_CONF_UNSET_PTR; 2350 conf->upstream.hide_headers = NGX_CONF_UNSET_PTR;
2342 conf->upstream.pass_headers = NGX_CONF_UNSET_PTR; 2351 conf->upstream.pass_headers = NGX_CONF_UNSET_PTR;
2343 2352
2579 ngx_conf_merge_value(conf->upstream.cache_lock, 2588 ngx_conf_merge_value(conf->upstream.cache_lock,
2580 prev->upstream.cache_lock, 0); 2589 prev->upstream.cache_lock, 0);
2581 2590
2582 ngx_conf_merge_msec_value(conf->upstream.cache_lock_timeout, 2591 ngx_conf_merge_msec_value(conf->upstream.cache_lock_timeout,
2583 prev->upstream.cache_lock_timeout, 5000); 2592 prev->upstream.cache_lock_timeout, 5000);
2593
2594 ngx_conf_merge_value(conf->upstream.cache_revalidate,
2595 prev->upstream.cache_revalidate, 0);
2584 2596
2585 #endif 2597 #endif
2586 2598
2587 ngx_conf_merge_value(conf->upstream.pass_request_headers, 2599 ngx_conf_merge_value(conf->upstream.pass_request_headers,
2588 prev->upstream.pass_request_headers, 1); 2600 prev->upstream.pass_request_headers, 1);