Skipping the proxy cache based on a cookie?

Dayo nginx-forum at
Wed Jan 19 22:58:21 MSK 2011

I think I am getting closer and hope someone can nudge me across the

My set up is now ...

if ($http_cookie !~* "mycookie=0") {
	add_header Cookie: "mycookie=1";

The idea being that if mycookie is not 0 (which should cover it not
being set), it is set to 1.  I then added cookie_MYCOOKIE to the bypass
and no cache parameters so that if it is set to 1, they are triggered.

The backend sets mycookie to 0 if it is 1 so that on subsequent
requests, the resource is served from the cache.

However unfortunately, the "add_header Cookie: "mycookie=1";" line does
not seem to be called at all.


Posted at Nginx Forum:,161969,167669#msg-167669

More information about the nginx mailing list