aboutsummaryrefslogtreecommitdiff
path: root/src/http/modules/ngx_http_fastcgi_module.c
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2010-06-04 09:17:09 +0000
committerIgor Sysoev <igor@sysoev.ru>2010-06-04 09:17:09 +0000
commite5d453228e39bbfb663aa3c0b45a9024bf8a9956 (patch)
tree3b315ba86ba78628d3a6714dfbe1efeee22009e4 /src/http/modules/ngx_http_fastcgi_module.c
parentca9259c0a5012ba2a2c61542a97524fb434e9179 (diff)
downloadnginx-e5d453228e39bbfb663aa3c0b45a9024bf8a9956.tar.gz
nginx-e5d453228e39bbfb663aa3c0b45a9024bf8a9956.zip
do not pass if-... headers for cacheable fastcgi responses
Diffstat (limited to 'src/http/modules/ngx_http_fastcgi_module.c')
-rw-r--r--src/http/modules/ngx_http_fastcgi_module.c63
1 files changed, 63 insertions, 0 deletions
diff --git a/src/http/modules/ngx_http_fastcgi_module.c b/src/http/modules/ngx_http_fastcgi_module.c
index 233b25abb..471e9e339 100644
--- a/src/http/modules/ngx_http_fastcgi_module.c
+++ b/src/http/modules/ngx_http_fastcgi_module.c
@@ -536,6 +536,17 @@ static ngx_str_t ngx_http_fastcgi_hide_cache_headers[] = {
ngx_null_string
};
+
+static ngx_keyval_t ngx_http_fastcgi_cache_headers[] = {
+ { ngx_string("HTTP_IF_MODIFIED_SINCE"), ngx_string("") },
+ { ngx_string("HTTP_IF_UNMODIFIED_SINCE"), ngx_string("") },
+ { ngx_string("HTTP_IF_NONE_MATCH"), ngx_string("") },
+ { ngx_string("HTTP_IF_MATCH"), ngx_string("") },
+ { ngx_string("HTTP_RANGE"), ngx_string("") },
+ { ngx_string("HTTP_IF_RANGE"), ngx_string("") },
+ { ngx_null_string, ngx_null_string }
+};
+
#endif
@@ -2287,9 +2298,30 @@ ngx_http_fastcgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
conf->params_source = prev->params_source;
conf->headers_hash = prev->headers_hash;
+#if (NGX_HTTP_CACHE)
+
+ if (conf->params_source == NULL) {
+
+ if ((conf->upstream.cache == NULL)
+ == (prev->upstream.cache == NULL))
+ {
+ return NGX_CONF_OK;
+ }
+
+ /* 6 is a number of ngx_http_fastcgi_cache_headers entries */
+ conf->params_source = ngx_array_create(cf->pool, 6,
+ sizeof(ngx_keyval_t));
+ if (conf->params_source == NULL) {
+ return NGX_CONF_ERROR;
+ }
+ }
+#else
+
if (conf->params_source == NULL) {
return NGX_CONF_OK;
}
+
+#endif
}
conf->params_len = ngx_array_create(cf->pool, 64, 1);
@@ -2309,6 +2341,37 @@ ngx_http_fastcgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
}
src = conf->params_source->elts;
+
+#if (NGX_HTTP_CACHE)
+
+ if (conf->upstream.cache) {
+ ngx_keyval_t *h, *s;
+
+ for (h = ngx_http_fastcgi_cache_headers; h->key.len; h++) {
+
+ for (i = 0; i < conf->params_source->nelts; i++) {
+ if (ngx_strcasecmp(h->key.data, src[i].key.data) == 0) {
+ goto next;
+ }
+ }
+
+ s = ngx_array_push(conf->params_source);
+ if (s == NULL) {
+ return NGX_CONF_ERROR;
+ }
+
+ *s = *h;
+
+ src = conf->params_source->elts;
+
+ next:
+
+ h++;
+ }
+ }
+
+#endif
+
for (i = 0; i < conf->params_source->nelts; i++) {
if (src[i].key.len > sizeof("HTTP_") - 1