mirror of
https://github.com/nginx/nginx.git
synced 2025-06-29 02:30:39 +08:00
if_modified_since
This commit is contained in:
parent
15fbaa6612
commit
863325fe98
@ -51,6 +51,7 @@ static
|
|||||||
ngx_int_t ngx_http_not_modified_header_filter(ngx_http_request_t *r)
|
ngx_int_t ngx_http_not_modified_header_filter(ngx_http_request_t *r)
|
||||||
{
|
{
|
||||||
time_t ims;
|
time_t ims;
|
||||||
|
ngx_http_core_loc_conf_t *clcf;
|
||||||
|
|
||||||
if (r->headers_out.status != NGX_HTTP_OK
|
if (r->headers_out.status != NGX_HTTP_OK
|
||||||
|| r != r->main
|
|| r != r->main
|
||||||
@ -66,16 +67,21 @@ ngx_int_t ngx_http_not_modified_header_filter(ngx_http_request_t *r)
|
|||||||
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
||||||
"http ims:%d lm:%d", ims, r->headers_out.last_modified_time);
|
"http ims:%d lm:%d", ims, r->headers_out.last_modified_time);
|
||||||
|
|
||||||
/*
|
if (ims != r->headers_out.last_modified_time) {
|
||||||
* I think that the equality of the dates is correcter
|
|
||||||
*/
|
clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
|
||||||
|
|
||||||
|
if (clcf->if_modified_since == 0
|
||||||
|
|| ims < r->headers_out.last_modified_time)
|
||||||
|
{
|
||||||
|
return ngx_http_next_header_filter(r);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (ims == r->headers_out.last_modified_time) {
|
|
||||||
r->headers_out.status = NGX_HTTP_NOT_MODIFIED;
|
r->headers_out.status = NGX_HTTP_NOT_MODIFIED;
|
||||||
r->headers_out.content_type.len = 0;
|
r->headers_out.content_type.len = 0;
|
||||||
ngx_http_clear_content_length(r);
|
ngx_http_clear_content_length(r);
|
||||||
ngx_http_clear_accept_ranges(r);
|
ngx_http_clear_accept_ranges(r);
|
||||||
}
|
|
||||||
|
|
||||||
return ngx_http_next_header_filter(r);
|
return ngx_http_next_header_filter(r);
|
||||||
}
|
}
|
||||||
|
@ -108,6 +108,13 @@ 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_null_string, 0 }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
#if (NGX_HTTP_GZIP)
|
#if (NGX_HTTP_GZIP)
|
||||||
|
|
||||||
static ngx_conf_enum_t ngx_http_gzip_http_version[] = {
|
static ngx_conf_enum_t ngx_http_gzip_http_version[] = {
|
||||||
@ -515,6 +522,13 @@ static ngx_command_t ngx_http_core_commands[] = {
|
|||||||
offsetof(ngx_http_core_loc_conf_t, server_tokens),
|
offsetof(ngx_http_core_loc_conf_t, server_tokens),
|
||||||
NULL },
|
NULL },
|
||||||
|
|
||||||
|
{ ngx_string("if_modified_since"),
|
||||||
|
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
||||||
|
ngx_conf_set_enum_slot,
|
||||||
|
NGX_HTTP_LOC_CONF_OFFSET,
|
||||||
|
offsetof(ngx_http_core_loc_conf_t, if_modified_since),
|
||||||
|
&ngx_http_core_if_modified_since },
|
||||||
|
|
||||||
{ ngx_string("error_page"),
|
{ ngx_string("error_page"),
|
||||||
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF
|
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF
|
||||||
|NGX_CONF_2MORE,
|
|NGX_CONF_2MORE,
|
||||||
@ -2663,6 +2677,7 @@ ngx_http_core_create_loc_conf(ngx_conf_t *cf)
|
|||||||
lcf->client_body_buffer_size = NGX_CONF_UNSET_SIZE;
|
lcf->client_body_buffer_size = NGX_CONF_UNSET_SIZE;
|
||||||
lcf->client_body_timeout = NGX_CONF_UNSET_MSEC;
|
lcf->client_body_timeout = NGX_CONF_UNSET_MSEC;
|
||||||
lcf->satisfy = NGX_CONF_UNSET_UINT;
|
lcf->satisfy = NGX_CONF_UNSET_UINT;
|
||||||
|
lcf->if_modified_since = NGX_CONF_UNSET_UINT;
|
||||||
lcf->internal = NGX_CONF_UNSET;
|
lcf->internal = NGX_CONF_UNSET;
|
||||||
lcf->client_body_in_file_only = NGX_CONF_UNSET;
|
lcf->client_body_in_file_only = NGX_CONF_UNSET;
|
||||||
lcf->sendfile = NGX_CONF_UNSET;
|
lcf->sendfile = NGX_CONF_UNSET;
|
||||||
@ -2852,6 +2867,8 @@ ngx_http_core_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
|
|||||||
|
|
||||||
ngx_conf_merge_uint_value(conf->satisfy, prev->satisfy,
|
ngx_conf_merge_uint_value(conf->satisfy, prev->satisfy,
|
||||||
NGX_HTTP_SATISFY_ALL);
|
NGX_HTTP_SATISFY_ALL);
|
||||||
|
ngx_conf_merge_uint_value(conf->if_modified_since, prev->if_modified_since,
|
||||||
|
0);
|
||||||
ngx_conf_merge_value(conf->internal, prev->internal, 0);
|
ngx_conf_merge_value(conf->internal, prev->internal, 0);
|
||||||
ngx_conf_merge_value(conf->client_body_in_file_only,
|
ngx_conf_merge_value(conf->client_body_in_file_only,
|
||||||
prev->client_body_in_file_only, 0);
|
prev->client_body_in_file_only, 0);
|
||||||
|
@ -299,6 +299,7 @@ struct ngx_http_core_loc_conf_s {
|
|||||||
time_t keepalive_header; /* keepalive_timeout */
|
time_t keepalive_header; /* keepalive_timeout */
|
||||||
|
|
||||||
ngx_uint_t satisfy; /* satisfy */
|
ngx_uint_t satisfy; /* satisfy */
|
||||||
|
ngx_uint_t if_modified_since; /* if_modified_since */
|
||||||
|
|
||||||
ngx_flag_t internal; /* internal */
|
ngx_flag_t internal; /* internal */
|
||||||
ngx_flag_t client_body_in_file_only; /* client_body_in_file_only */
|
ngx_flag_t client_body_in_file_only; /* client_body_in_file_only */
|
||||||
|
Loading…
Reference in New Issue
Block a user