<div dir="ltr">I'm a little unclear as to when <span style="color:rgb(0,0,0);font-family:Menlo;font-size:11px;font-variant-ligatures:no-common-ligatures;text-align:justify">ngx_http_get_flushed_variable() </span>should be used rather than <span style="color:rgb(0,0,0);font-family:monospace;font-size:medium;text-align:justify">ngx_http_get_indexed_variable()</span>. The dev guide is a little sparse, so I'm hoping someone could help.<div><br></div><div>The relevant flags within the <font face="monospace">ngx_variable_value_t</font> with their dev guide descriptions (followed by my interpretation) are:</div><div><br><p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="gmail-s2" style="font-variant-ligatures:no-common-ligatures;color:rgb(47,180,29)">unsigned</span><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><span class="gmail-Apple-converted-space">    </span>valid:</span><span class="gmail-s3" style="font-variant-ligatures:no-common-ligatures;color:rgb(180,36,25)">1</span><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">;</span></p><ul class="gmail-compact" style="margin:0.5em 0px 1em 1em;padding:0px 0.5em;color:rgb(0,0,0);font-family:sans-serif;font-size:medium"><li style="text-align:justify;padding:0px 0px 0px 1px"><code>valid</code> — The value is valid</li></ul><div style="">The function used to generate the value has indeed been able to create a valid value. When this is an indexed variable, it is then stored within the <span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0);font-family:Menlo;font-size:11px">ngx_http_request_t.variables </span>array so that it can be reused for this request without needing to be re-generated</div>





<div style=""><br><p class="gmail-p1" style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;text-align:start;margin:0px;color:rgb(0,0,0)"><span class="gmail-s2" style="font-variant-ligatures:no-common-ligatures;color:rgb(47,180,29)">unsigned</span><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><span class="gmail-Apple-converted-space">    </span>not_found:</span><span class="gmail-s3" style="font-variant-ligatures:no-common-ligatures;color:rgb(180,36,25)">1</span><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">;</span></p></div><ul class="gmail-compact" style="margin:0.5em 0px 1em 1em;padding:0px 0.5em;color:rgb(0,0,0);font-family:sans-serif;font-size:medium"><li style="text-align:justify;padding:0px 0px 0px 1px"><code>not_found</code> — The variable was not found and thus the <code>data</code> and <code>len</code> fields are irrelevant; this can happen, for example, with variables like <code>$arg_foo</code> when a corresponding argument was not passed in a request</li></ul><div style="">This could not be generated, and re-attempting to do so won't succeed. As such (for indexed variables), this is negatively cached within the same <span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0);font-family:Menlo;font-size:11px">ngx_http_request_t.variables </span>array.</div><div style=""><br><p class="gmail-p1" style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;text-align:start;margin:0px;color:rgb(0,0,0)"><span class="gmail-s2" style="font-variant-ligatures:no-common-ligatures;color:rgb(47,180,29)">unsigned</span><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><span class="gmail-Apple-converted-space">    </span>no_cacheable:</span><span class="gmail-s3" style="font-variant-ligatures:no-common-ligatures;color:rgb(180,36,25)">1</span><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">;</span></p></div><ul class="gmail-compact" style="margin:0.5em 0px 1em 1em;padding:0px 0.5em;color:rgb(0,0,0);font-family:sans-serif;font-size:medium"><li style="text-align:justify;padding:0px 0px 0px 1px"><code>no_cacheable</code> — Do not cache result</li></ul><div style="text-align:justify"><span style="color:rgb(0,0,0);font-family:sans-serif;font-size:medium">The difference between functions is that the </span><code style="color:rgb(0,0,0)">ngx_http_get_indexed_variable()</code><span style="color:rgb(0,0,0);font-family:sans-serif;font-size:medium"> </span><span style="color:rgb(0,0,0);font-family:sans-serif;font-size:medium">returns a cached value and</span><span style="color:rgb(0,0,0);font-family:sans-serif;font-size:medium"> </span><code style="color:rgb(0,0,0)">ngx_http_get_flushed_variable()</code><span style="color:rgb(0,0,0);font-family:sans-serif;font-size:medium"> </span><span style="color:rgb(0,0,0);font-family:sans-serif;font-size:medium">flushes the cache for non-cacheable variables.</span><br></div><div style="text-align:justify"><br class="gmail-Apple-interchange-newline"></div><div style="text-align:justify"><p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal">That is, <span style="color:rgb(0,0,0);font-family:monospace;font-size:medium">no_cacheable</span> is only meaningful when <span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0);font-family:Menlo;font-size:11px">ngx_http_get_flushed_variable() </span>is called rather than <span style="color:rgb(0,0,0);font-family:monospace;font-size:medium">ngx_http_get_indexed_variable()</span>, when it causes the cached value to be regenerated.  </p><p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal"><span style="text-align:start"><br></span></p><p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal"><span style="text-align:start"><br></span></p><p class="gmail-p1" style="text-align:start;margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal">Are there any guidelines on when <font face="monospace">ngx_http_get_flushed_variable()</font> should be used instead of <font face="monospace">ngx_http_get_indexed_variable()</font>?<br></p><p class="gmail-p1" style="text-align:left;margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal"><br></p><p class="gmail-p1" style="text-align:left;margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal">It seems like it is 'practically never', but why for example does <span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0);font-family:Menlo;font-size:11px">ngx_http_get_variable() </span>use<font color="#000000" face="Menlo"><span style="font-size:11px;font-variant-ligatures:no-common-ligatures"> </span></font></p><p class="gmail-p1" style="text-align:left;margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal"><span style="font-family:monospace">ngx_http_get_flushed_variable()</span>?</p><p class="gmail-p1" style="text-align:left;margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal"> </p><p class="gmail-p1" style="text-align:left;margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal">TIA</p><p class="gmail-p1" style="text-align:left;margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal"><br></p><p class="gmail-p1" style="text-align:left;margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal">Chris</p></div></div></div>