Skipping the proxy cache based on a cookie?

António P. P. Almeida appa at perusio.net
Wed Jan 19 00:52:12 MSK 2011


On 18 Jan 2011 21h34 WET, nginx-forum at nginx.us wrote:

> Just came back to this as I have hit this wall and it would be very
> useful if the roxy no cache and proxy bypass could be triggered
> based on the [u]absence[/u] of a cookie.
>
> I need to pass first time visitors to the backend and I need to make
> sure the content they get is not cached. As they are first time
> visitors, I can't rely on the presence of a cookie to tell this and
> the only way I can think off is to check for the absence of a
> cookie.
>
> Any chance of implementing ...
> [code]
> proxy_cache_bypass_empty $cookie_COOKIE;
> proxy_no_cache_empty $cookie_COOKIE;
> [/code]

If I understand your question, wouldn't this do the trick?

if ($cookie_COOKIE = "") {
  set $cookie_no_cache true;
}

Now it works as "usual".
--- appa






More information about the nginx mailing list