Welcome! Log In Create A New Profile

Advanced

Help: cache or not by cookie

June 20, 2009 06:54AM
The requirement is:

When a cookie exist, not return cached file and not cache the response, if the cookie not exist, return cached file and . cache the response.

In the past, we use a standalone cacheserver, the configuration looks like below:

location / {
if ($http_cookie ~* xxx ) {
set $cache 0;
}

if ($cache = 1) {
proxy_pass http://cacheserver;
break;
}

location ~* \.php {
fastcgi_pass 127.0.0.1:8080;
}

So, cookie-non-exist visit will be directed to cacheserver, and cookie-exist visit will be directed to fastcgi_pass.

So if we want to remove the cacheserver, and use nginx's cache feature, we need to configure like this:

location ~* \.php {
fastcgi_pass 127.0.0.1:8080;
fastcgi_cache php;
fastcgi_cache_key $request_uri;
}

Then how can we set cookie-non-exist visits to use cache and cookie-exist visit not to use cache?



Edited 1 time(s). Last edit at 06/20/2009 06:56AM by tonyy.
Subject Author Posted

Help: cache or not by cookie

tonyy June 20, 2009 06:54AM

Re: Help: cache or not by cookie

Igor Sysoev June 20, 2009 09:24AM

Re: Help: cache or not by cookie

Igor Sysoev June 22, 2009 07:32AM

Re: Help: cache or not by cookie

tonyy June 20, 2009 10:04AM

Re: Help: cache or not by cookie

tonyy June 22, 2009 09:53AM

Re: Help: cache or not by cookie

nfn July 08, 2009 06:40PM

Re: Help: cache or not by cookie

Igor Sysoev July 09, 2009 03:05AM

Re: Help: cache or not by cookie

nfn July 09, 2009 06:05AM

Re: Help: cache or not by cookie

Igor Sysoev July 09, 2009 10:26AM

Re: Help: cache or not by cookie

ned0r September 03, 2009 06:53PM

Re: Help: cache or not by cookie

Igor Sysoev September 04, 2009 06:10AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 220
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready