comparison src/http/ngx_http_upstream.c @ 4176:2b5151a2300b

Fixed cache bypass caching of non-cacheable replies (ticket #21). If cache was bypassed with proxy_cache_bypass, cache-controlling headers (Cache-Control, Expires) wasn't considered and response was cached even if it was actually non-cacheable. Patch by John Ferlito.
author Maxim Dounin <mdounin@mdounin.ru>
date Wed, 05 Oct 2011 10:14:21 +0000
parents 65c1c241d70e
children 75d2388bd6b9
comparison
equal deleted inserted replaced
4157:9d59a8eda373 4176:2b5151a2300b
681 681
682 r->cache = NULL; 682 r->cache = NULL;
683 return NGX_DECLINED; 683 return NGX_DECLINED;
684 } 684 }
685 685
686 u->cacheable = 1;
687
686 switch (ngx_http_test_predicates(r, u->conf->cache_bypass)) { 688 switch (ngx_http_test_predicates(r, u->conf->cache_bypass)) {
687 689
688 case NGX_ERROR: 690 case NGX_ERROR:
689 return NGX_ERROR; 691 return NGX_ERROR;
690 692
693 return NGX_DECLINED; 695 return NGX_DECLINED;
694 696
695 default: /* NGX_OK */ 697 default: /* NGX_OK */
696 break; 698 break;
697 } 699 }
698
699 u->cacheable = 1;
700 700
701 c = r->cache; 701 c = r->cache;
702 702
703 c->min_uses = u->conf->cache_min_uses; 703 c->min_uses = u->conf->cache_min_uses;
704 c->body_start = u->conf->buffer_size; 704 c->body_start = u->conf->buffer_size;
2179 2179
2180 if (ngx_http_file_cache_create(r) != NGX_OK) { 2180 if (ngx_http_file_cache_create(r) != NGX_OK) {
2181 ngx_http_upstream_finalize_request(r, u, 0); 2181 ngx_http_upstream_finalize_request(r, u, 0);
2182 return; 2182 return;
2183 } 2183 }
2184
2185 u->cacheable = 1;
2186 } 2184 }
2187 2185
2188 break; 2186 break;
2189 } 2187 }
2190 2188