Proxy cache only is cookie present

Hello,

I’m using nginx/0.7.62 to proxy requests to apache2+mod_php and I would
like to cache content only if a cookie has a value present: “usergroup =
1”

How am I able to archive this?

Thanks

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,26770,26770#msg-26770

Hi,

I’ve manage to insert a cookie named “guests=guests” in my app, because
I have some doubts about the $cookie_COOKIE variable … I don’t know is
matched the name or the value of the cookie.

In my tests, this is what I have:

    proxy_cache_path /var/cache/nginx levels=1:2 

keys_zone=members:10m inactive=5m max_size=500m;

    location /members/ {
        proxy_pass  http://apache;
        proxy_cache members;
        proxy_cache_key "$host$request_uri$cookie_guests";
        proxy_ignore_headers Cache-Control Expires;
        proxy_cache_valid 200 301 302 10m;
        proxy_pass_header Set-Cookie;
    }

With this I can cache, but all others (registered) users will get the
same cached page.

Need some help here :slight_smile:

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,26770,27483#msg-27483

Hello,

Sorry for bumping this, but i can’t get this to work the way I want.
Any ideas?

Thanks

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,26770,27932#msg-27932