<font color="#000099"><br></font><br><div class="gmail_quote">On Thu, Feb 9, 2012 at 2:19 PM, Maxim Dounin <span dir="ltr"><<a href="mailto:mdounin@mdounin.ru">mdounin@mdounin.ru</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

Hello!<br>
<div class="im"><br>
On Thu, Feb 09, 2012 at 12:34:33PM +0530, Quintin Par wrote:<br>
<br>
> Picking up an old thread for caching<br>
><br>
> <a href="http://nginx.2469901.n2.nabble.com/Help-cache-or-not-by-cookie-td3124462.html" target="_blank">http://nginx.2469901.n2.nabble.com/Help-cache-or-not-by-cookie-td3124462.html</a><br>
><br>
> Igor talks about caching by<br>
><br>
> “No, currently the single way is:<br>
><br>
> 1) add the cookie in proxy_cache_key<br>
><br>
>    proxy_cache_key  "<a href="http://cacheserver" target="_blank">http://cacheserver</a>$request_uri $cookie_name";<br>
><br>
> 2) add "X-Accel-Expires: 0" in response with the cookie.”<br>
><br>
</div>> But from my understanding of “*X-Accel-Expires” *it expires the cache in<br>
<div class="im">> the cache repository as given below<br>
><br>
> “Sets when to expire the file in the internal Nginx cache, if one is used.”<br>
><br>
> Does this not mean that when I set cookie and pass “X-Accel-Expires: 0” it<br>
> expires the cache for the non logged in user too, for that cache key? A new<br>
> cache entry will then have to be created, right?<br>
<br>
</div>No.  X-Accel-Expires will prevent the particular response from<br>
being cached, but won't delete existing cache entry.<br></blockquote><div><br></div><div>So what should I do to delete a particular cache entry? </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


<div class="im"><br>
><br>
> Should I go with “Cache-Control: max-age=0” approach?<br>
<br>
</div>The only difference between "X-Accel-Expires: 0" and<br>
"Cache-Contro: max-age=0" is that the former won't be passed to<br>
client.<br>
<br>
As for the use-case in general (i.e. only use cache for users<br>
without cookie), in recent versions it is enough to do<br>
<br>
    proxy_cache_bypass $cookie_name;<br>
    proxy_no_cache $cookie_name;<br>
<br>
I.e.: don't respond from cache to users with cookie<br>
(proxy_cache_bypass), don't store to cache responses for users<br>
with cookie (proxy_no_cache).<br>
<br>
Moreover, responses with Set-Cookie won't be cached by default,<br>
too.  So basically just placing the above into config is enough,<br>
no further changes to a backend code required.<br>
<br>
Maxim Dounin<br>
<br>
_______________________________________________<br>
nginx mailing list<br>
<a href="mailto:nginx@nginx.org">nginx@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx" target="_blank">http://mailman.nginx.org/mailman/listinfo/nginx</a></blockquote></div><br>