mirror of
https://github.com/nginx/nginx.git
synced 2025-06-08 02:02:38 +08:00
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.
This commit is contained in:
parent
105dd42bd7
commit
d07d598c28
@ -2528,14 +2528,24 @@ ngx_http_upstream_intercept_errors(ngx_http_request_t *r,
|
|||||||
#if (NGX_HTTP_CACHE)
|
#if (NGX_HTTP_CACHE)
|
||||||
|
|
||||||
if (r->cache) {
|
if (r->cache) {
|
||||||
|
|
||||||
|
if (u->cacheable) {
|
||||||
time_t valid;
|
time_t valid;
|
||||||
|
|
||||||
valid = ngx_http_file_cache_valid(u->conf->cache_valid, status);
|
valid = r->cache->valid_sec;
|
||||||
|
|
||||||
|
if (valid == 0) {
|
||||||
|
valid = ngx_http_file_cache_valid(u->conf->cache_valid,
|
||||||
|
status);
|
||||||
if (valid) {
|
if (valid) {
|
||||||
r->cache->valid_sec = ngx_time() + valid;
|
r->cache->valid_sec = ngx_time() + valid;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (valid) {
|
||||||
r->cache->error = status;
|
r->cache->error = status;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ngx_http_file_cache_free(r->cache, u->pipe->temp_file);
|
ngx_http_file_cache_free(r->cache, u->pipe->temp_file);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user