comparison src/http/ngx_http_upstream.c @ 7117:dbd77a638eb7

Cache: fixed caching of intercepted errors (ticket #1382). When caching intercepted errors, previous behaviour was to use proxy_cache_valid times specified, regardless of various cache control headers present in the response. Fix is to check u->cacheable and use u->cache->valid_sec as set by various cache control response headers, similar to how we do this in the normal caching code path.
author Maxim Dounin <mdounin@mdounin.ru>
date Tue, 03 Oct 2017 18:19:27 +0300
parents 46ddff109e72
children b8fc701daf8e
comparison
equal deleted inserted replaced
7116:46ddff109e72 7117:dbd77a638eb7
2526 } 2526 }
2527 2527
2528 #if (NGX_HTTP_CACHE) 2528 #if (NGX_HTTP_CACHE)
2529 2529
2530 if (r->cache) { 2530 if (r->cache) {
2531 time_t valid; 2531
2532 2532 if (u->cacheable) {
2533 valid = ngx_http_file_cache_valid(u->conf->cache_valid, status); 2533 time_t valid;
2534 2534
2535 if (valid) { 2535 valid = r->cache->valid_sec;
2536 r->cache->valid_sec = ngx_time() + valid; 2536
2537 r->cache->error = status; 2537 if (valid == 0) {
2538 valid = ngx_http_file_cache_valid(u->conf->cache_valid,
2539 status);
2540 if (valid) {
2541 r->cache->valid_sec = ngx_time() + valid;
2542 }
2543 }
2544
2545 if (valid) {
2546 r->cache->error = status;
2547 }
2538 } 2548 }
2539 2549
2540 ngx_http_file_cache_free(r->cache, u->pipe->temp_file); 2550 ngx_http_file_cache_free(r->cache, u->pipe->temp_file);
2541 } 2551 }
2542 #endif 2552 #endif