From 2c33648e52a6f355b426e617dd3fc577961c5193 Mon Sep 17 00:00:00 2001 From: Igor Sysoev Date: Tue, 10 Feb 2009 15:05:05 +0000 Subject: [PATCH] if_modified_since off --- src/http/modules/ngx_http_not_modified_filter_module.c | 10 +++++++--- src/http/ngx_http_core_module.c | 7 ++++--- src/http/ngx_http_core_module.h | 5 +++++ 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/http/modules/ngx_http_not_modified_filter_module.c b/src/http/modules/ngx_http_not_modified_filter_module.c index 389a3a93a..feed9cf54 100644 --- a/src/http/modules/ngx_http_not_modified_filter_module.c +++ b/src/http/modules/ngx_http_not_modified_filter_module.c @@ -61,6 +61,12 @@ ngx_int_t ngx_http_not_modified_header_filter(ngx_http_request_t *r) return ngx_http_next_header_filter(r); } + clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); + + if (clcf->if_modified_since == NGX_HTTP_IMS_OFF) { + return ngx_http_next_header_filter(r); + } + ims = ngx_http_parse_time(r->headers_in.if_modified_since->value.data, r->headers_in.if_modified_since->value.len); @@ -69,9 +75,7 @@ ngx_int_t ngx_http_not_modified_header_filter(ngx_http_request_t *r) if (ims != r->headers_out.last_modified_time) { - clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); - - if (clcf->if_modified_since == 0 + if (clcf->if_modified_since == NGX_HTTP_IMS_EXACT || ims < r->headers_out.last_modified_time) { return ngx_http_next_header_filter(r); diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c index 9890fbb92..a21da0f3b 100644 --- a/src/http/ngx_http_core_module.c +++ b/src/http/ngx_http_core_module.c @@ -112,8 +112,9 @@ static ngx_conf_enum_t ngx_http_core_satisfy[] = { static ngx_conf_enum_t ngx_http_core_if_modified_since[] = { - { ngx_string("exact"), 0 }, - { ngx_string("before"), 1 }, + { ngx_string("off"), NGX_HTTP_IMS_OFF }, + { ngx_string("exact"), NGX_HTTP_IMS_EXACT }, + { ngx_string("before"), NGX_HTTP_IMS_BEFORE }, { ngx_null_string, 0 } }; @@ -3052,7 +3053,7 @@ ngx_http_core_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child) ngx_conf_merge_uint_value(conf->satisfy, prev->satisfy, NGX_HTTP_SATISFY_ALL); ngx_conf_merge_uint_value(conf->if_modified_since, prev->if_modified_since, - 0); + NGX_HTTP_IMS_EXACT); ngx_conf_merge_value(conf->internal, prev->internal, 0); ngx_conf_merge_value(conf->client_body_in_file_only, prev->client_body_in_file_only, 0); diff --git a/src/http/ngx_http_core_module.h b/src/http/ngx_http_core_module.h index 46acb2b4f..21a53552e 100644 --- a/src/http/ngx_http_core_module.h +++ b/src/http/ngx_http_core_module.h @@ -28,6 +28,11 @@ #define NGX_HTTP_SATISFY_ANY 1 +#define NGX_HTTP_IMS_OFF 0 +#define NGX_HTTP_IMS_EXACT 1 +#define NGX_HTTP_IMS_BEFORE 2 + + typedef struct ngx_http_location_tree_node_s ngx_http_location_tree_node_t; typedef struct ngx_http_core_loc_conf_s ngx_http_core_loc_conf_t;