On Fri, Jan 15, 2010 at 2:37 PM, agentzh <span dir="ltr"><<a href="mailto:agentzh@gmail.com">agentzh@gmail.com</a>></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 <<a href="mailto:vinay.ys@gmail.com">vinay.ys@gmail.com</a>> wrote:<br>
><br>
> Hi,<br>
> 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>
> Currently I'm trying following config<br>
> location /album {<br>
> if ($cookie_logintoken ~* "") {<br>
> set $cache_key $scheme$proxy_host$uri$is_args$args;<br>
> }<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>