[PATCH] During background update, nginx can't add "Range" header
Sangdeuk Kwon
sangdeuk.kwon at quantil.com
Thu Jul 23 05:29:16 UTC 2020
# HG changeset patch
# User Sangdeuk Kwon <sangdeuk.kwon at quantil.com>
# Date 1595481798 -32400
# Thu Jul 23 14:23:18 2020 +0900
# Node ID 90e5ccf7c229322079ba1b61b4241ed69dfc09b2
# Parent 4f30f75dbdf33d6fae9e70086e0df5cbab7db027
During background update, nginx can't add "Range" header
If the configuration is "slice enabled" and "proxy_cache_use_stale
updating"
and "proxy_cache_background_update on",
nginx can't get "$slice_range" value during background update.
nginx sends request to upstream without "Range" header.
The re-fetched content is saved by cache key of absent "$slice_range".
So, nginx always serves stale content even though after re-fetching new
content.
slice 1k;
proxy_cache_use_stale updating;
proxy_cache_background_update on;
proxy_cache_key "$host$uri[$slice_range]
diff -r 4f30f75dbdf3 -r 90e5ccf7c229
src/http/modules/ngx_http_slice_filter_module.c
--- a/src/http/modules/ngx_http_slice_filter_module.c Tue Jul 21 20:34:29
2020 +0300
+++ b/src/http/modules/ngx_http_slice_filter_module.c Thu Jul 23 14:23:18
2020 +0900
@@ -400,9 +400,12 @@
ngx_http_slice_loc_conf_t *slcf;
ctx = ngx_http_get_module_ctx(r, ngx_http_slice_filter_module);
+ if (r->background && r != r->main && r->main != r->parent) {
+ ctx = ngx_http_get_module_ctx(r->parent,
ngx_http_slice_filter_module);
+ }
if (ctx == NULL) {
- if (r != r->main || r->headers_out.status) {
+ if ((r != r->main && !r->background) || r->headers_out.status) {
v->not_found = 1;
return NGX_OK;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20200723/9e061cd6/attachment.htm>
More information about the nginx-devel
mailing list