<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hi,<br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On 23 Jul 2020, at 08:29, Sangdeuk Kwon <<a href="mailto:sangdeuk.kwon@quantil.com" class="">sangdeuk.kwon@quantil.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""># HG changeset patch <br class=""># User Sangdeuk Kwon <<a href="mailto:sangdeuk.kwon@quantil.com" class="">sangdeuk.kwon@quantil.com</a>> <br class=""># Date 1595481798 -32400 <br class=""># Thu Jul 23 14:23:18 2020 +0900 <br class=""># Node ID 90e5ccf7c229322079ba1b61b4241ed69dfc09b2 <br class=""># Parent 4f30f75dbdf33d6fae9e70086e0df5cbab7db027 <br class="">During background update, nginx can't add "Range" header <br class=""> <br class="">If the configuration is "slice enabled" and "proxy_cache_use_stale updating" <br class="">and "proxy_cache_background_update on", <br class="">nginx can't get "$slice_range" value during background update. <br class="">nginx sends request to upstream without "Range" header. <br class="">The re-fetched content is saved by cache key of absent "$slice_range". <br class="">So, nginx always serves stale content even though after re-fetching new content.<br class=""></div></div></blockquote><div><br class=""></div><div>This is correct. The slice module does not work with background updates.</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""> <br class="">slice 1k; <br class="">proxy_cache_use_stale updating; <br class="">proxy_cache_background_update on; <br class="">proxy_cache_key "$host$uri[$slice_range] <br class=""> <br class="">diff -r 4f30f75dbdf3 -r 90e5ccf7c229 src/http/modules/ngx_http_slice_filter_module.c<br class="">--- a/src/http/modules/ngx_http_slice_filter_module.c Tue Jul 21 20:34:29 2020 +0300<br class="">+++ b/src/http/modules/ngx_http_slice_filter_module.c Thu Jul 23 14:23:18 2020 +0900<br class="">@@ -400,9 +400,12 @@ <br class=""> ngx_http_slice_loc_conf_t *slcf; <br class=""> <br class=""> ctx = ngx_http_get_module_ctx(r, ngx_http_slice_filter_module); <br class="">+ if (r->background && r != r->main && r->main != r->parent) { <br class="">+ ctx = ngx_http_get_module_ctx(r->parent, ngx_http_slice_filter_module);<br class="">+ } </div></div></blockquote><div><br class=""></div><div>Here you’re trying to get the parent request’s context to access the slice range.</div><div>But slice range is being constantly updated. So there’s no guarantee that you get</div><div>the right slice range.</div><div><br class=""></div>The right solution would be to pass the slice range to the background update</div><div>subrequest as an argument or a part of uri. But that does not seem to be possible</div><div>within the current background update implementation. Probably there’s a way to save</div><div>and then access the right slice using njs.</div><div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""> <br class=""> <br class=""> if (ctx == NULL) { <br class="">- if (r != r->main || r->headers_out.status) { <br class="">+ if ((r != r->main && !r->background) || r->headers_out.status) { <br class=""> v->not_found = 1; <br class=""> return NGX_OK; <br class=""> }</div></div></blockquote><div><br class=""></div><div>Here you are creating a new ctx for the background update subrequest,</div><div>which suggests that you want to update the entire response rather that</div><div>only one slice.</div><br class=""><blockquote type="cite" class=""><div class="">
_______________________________________________<br class="">nginx-devel mailing list<br class=""><a href="mailto:nginx-devel@nginx.org" class="">nginx-devel@nginx.org</a><br class="">http://mailman.nginx.org/mailman/listinfo/nginx-devel</div></blockquote></div><br class=""></body></html>