Skip to content

Commit 00b30f7

Browse files
committed
implemented the srcache_store_no_cache directive; now by default, we do not store responses with the header "Cache-Control: no-cache" into the cache.
1 parent a5da88a commit 00b30f7

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

src/ngx_http_srcache_filter_module.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,13 @@ static ngx_command_t ngx_http_srcache_commands[] = {
136136
offsetof(ngx_http_srcache_loc_conf_t, store_no_store),
137137
NULL },
138138

139+
{ ngx_string("srcache_store_no_cache"),
140+
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
141+
ngx_conf_set_flag_slot,
142+
NGX_HTTP_LOC_CONF_OFFSET,
143+
offsetof(ngx_http_srcache_loc_conf_t, store_no_cache),
144+
NULL },
145+
139146
ngx_null_command
140147
};
141148

@@ -613,6 +620,7 @@ ngx_http_srcache_create_loc_conf(ngx_conf_t *cf)
613620
conf->req_cache_control = NGX_CONF_UNSET;
614621
conf->store_private = NGX_CONF_UNSET;
615622
conf->store_no_store = NGX_CONF_UNSET;
623+
conf->store_no_cache = NGX_CONF_UNSET;
616624

617625
return conf;
618626
}
@@ -649,6 +657,7 @@ ngx_http_srcache_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
649657
ngx_conf_merge_value(conf->req_cache_control, prev->req_cache_control, 0);
650658
ngx_conf_merge_value(conf->store_private, prev->store_private, 0);
651659
ngx_conf_merge_value(conf->store_no_store, prev->store_no_store, 0);
660+
ngx_conf_merge_value(conf->store_no_cache, prev->store_no_cache, 0);
652661

653662
return NGX_CONF_OK;
654663
}

src/ngx_http_srcache_filter_module.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ typedef struct {
3636
ngx_flag_t req_cache_control;
3737
ngx_flag_t store_private;
3838
ngx_flag_t store_no_store;
39+
ngx_flag_t store_no_cache;
3940

4041
unsigned postponed_to_access_phase_end;
4142
} ngx_http_srcache_loc_conf_t;

src/ngx_http_srcache_util.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,11 @@ ngx_http_srcache_response_no_cache(ngx_http_request_t *r,
473473
return NGX_OK;
474474
}
475475

476+
if (!conf->store_no_cache
477+
&& ngx_strlcasestrn(p, last, (u_char *) "no-cache", 8 - 1) != NULL)
478+
{
479+
return NGX_OK;
480+
}
476481
}
477482

478483
return NGX_DECLINED;

0 commit comments

Comments
 (0)