On Fri, Jan 15, 2010 at 2:37 PM, agentzh <span dir="ltr">&lt;<a href="mailto:agentzh@gmail.com">agentzh@gmail.com</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<div class="im">On Fri, Jan 15, 2010 at 4:06 PM, Vinay Y S &lt;<a href="mailto:vinay.ys@gmail.com">vinay.ys@gmail.com</a>&gt; wrote:<br>
&gt;<br>
&gt; Hi,<br>
&gt; For a given location, I want the requests to be cached only if a particular cookie is not present. How do I achieve that with nginx?<br>
&gt; Currently I&#39;m trying following config<br>
&gt;     location /album {<br>
&gt;         if ($cookie_logintoken ~* &quot;&quot;) {<br>
&gt;             set $cache_key $scheme$proxy_host$uri$is_args$args;<br>
&gt;         }<br>
<br>
</div>Please see this thread for a simple solution:<br>
<br>
    <a href="http://forum.nginx.org/read.php?2,25197" target="_blank">http://forum.nginx.org/read.php?2,25197</a><br>
<br>
Hope this helps.<br></blockquote><div><br></div><div>Could you please elaborate on it? There was no issues with $cache_key value being set in if block and being visible to proxy_cache_key directive. The issue is when the if condition is not satisfied and hence the $cache_key is not set, I was expecting the caching to get disabled altogether as proxy_cache_key was now being passed a uninitialized variable as parameter.</div>

<div><br></div><div>Thanks,</div><div>Vinay</div></div>