Cookie problem with proxy cache

Ole Laursen olau at
Wed Nov 18 23:41:53 MSK 2009

Gabriel Ramuglia <gabe at ...> writes:
> And then, of course, cookies will be sent even when trying to access
> things like images, css, js files, which will not be changing
> regardless of the cookie sent. So vary-cookie makes sense to me. I
> guess if I were caching software, I would just decide not to cache
> anything when it said vary-cookie, and would then ignore the cookies
> otherwise, and cache anyway, even if there were cookies. That seems to
> make the most sense to me.

Yes, exactly. The backend signals that a page depends on a cookie by sending a
Vary: cookie header. Nginx shouldn't cache and send such a page to everyone.

Here's the code in Varnish that handles the Vary header:

I think it constructs a regexp used when looking for a matching object. So my
assertion about Varnish was wrong, it actually caches the page, but it only
returns it to a client with the same cookie. Full vary supports looks like it's
some work:

But I'd be happy with just support for Vary: cookie that simply bypasses the
cache. I had a brief look at the nginx code, but I'm not sure where one would do
the change?


More information about the nginx mailing list