diff options
| author | Roman Arutyunyan <arut@nginx.com> | 2017-05-25 15:57:59 +0300 |
|---|---|---|
| committer | Roman Arutyunyan <arut@nginx.com> | 2017-05-25 15:57:59 +0300 |
| commit | 8644d9491ad3c0eb16bcda1d452aba326e1f4dae (patch) | |
| tree | 1425006b8569fe3059667742d484933ec9c0e7e5 /src/http/ngx_http_upstream.c | |
| parent | c83922b18ddc83f654c1d0df48a6ca1ee9938078 (diff) | |
| download | nginx-8644d9491ad3c0eb16bcda1d452aba326e1f4dae.tar.gz nginx-8644d9491ad3c0eb16bcda1d452aba326e1f4dae.tar.bz2 | |
Background subrequests for cache updates.
Previously, cache background update might not work as expected, making client
wait for it to complete before receiving the final part of a stale response.
This could happen if the response could not be sent to the client socket in one
filter chain call.
Now background cache update is done in a background subrequest. This type of
subrequest does not block any other subrequests or the main request.
Diffstat (limited to '')
| -rw-r--r-- | src/http/ngx_http_upstream.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c index fcfa2ad94..2a3bb163c 100644 --- a/src/http/ngx_http_upstream.c +++ b/src/http/ngx_http_upstream.c @@ -879,7 +879,7 @@ ngx_http_upstream_cache(ngx_http_request_t *r, ngx_http_upstream_t *u) case NGX_HTTP_CACHE_STALE: if (((u->conf->cache_use_stale & NGX_HTTP_UPSTREAM_FT_UPDATING) - || c->stale_updating) && !r->cache_updater + || c->stale_updating) && !r->background && u->conf->cache_background_update) { r->cache->background = 1; @@ -892,7 +892,7 @@ ngx_http_upstream_cache(ngx_http_request_t *r, ngx_http_upstream_t *u) case NGX_HTTP_CACHE_UPDATING: if (((u->conf->cache_use_stale & NGX_HTTP_UPSTREAM_FT_UPDATING) - || c->stale_updating) && !r->cache_updater) + || c->stale_updating) && !r->background) { u->cache_status = rc; rc = NGX_OK; @@ -1076,14 +1076,14 @@ ngx_http_upstream_cache_background_update(ngx_http_request_t *r, } if (ngx_http_subrequest(r, &r->uri, &r->args, &sr, NULL, - NGX_HTTP_SUBREQUEST_CLONE) + NGX_HTTP_SUBREQUEST_CLONE + |NGX_HTTP_SUBREQUEST_BACKGROUND) != NGX_OK) { return NGX_ERROR; } sr->header_only = 1; - sr->cache_updater = 1; return NGX_OK; } |
