Welcome! Log In Create A New Profile

Advanced

Re: fastcgi_cache_key with cookie

António P. P. Almeida
December 27, 2011 03:02AM
On 27 Dez 2011 07h46 WET, nginx-forum@nginx.us wrote:

> I've also tried this using the userid module I set a custom cookie
> like so
>
> userid on;
> userid_name "testid";
> userid_expires 100s;
>
> and set the fastcgi_cache_key like so
>
> fastcgi_cache_key
> $cookie_testid$request_method$scheme$host$request_uri
>
> the problem with this setup is when I login or logout, since the key
> is based on only $cookie_testid without $http_cookie, then the user
> will still see the logged in page even after logging out.
> Alternatively how would I user the cache purge module to purge the
> key when the user hits the login or logout button? this is the
> sample config

I think you can do it with map. Untested:


map $http_cookie $logged_in {
default 0;
~SESS 1;
}

Define two locations each with a different cache (anon/authenticated):

The default cache is the anon:

location @anon-cache {
error_page 418 @auth-cache;
if ($logged_in) {
return 418;
}
userid_expires 0s;
... # fastcgi cache stuff for anon users
}



location @auth-cache {
# set the user id expires here to a positive value
# fastcgi cache for authenticated users
}


I never played with the userid module. So...

--- appa

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

fastcgi_cache_key with cookie

zenw December 27, 2011 12:13AM

Re: fastcgi_cache_key with cookie

António P. P. Almeida December 27, 2011 01:38AM

Re: fastcgi_cache_key with cookie

zenw December 27, 2011 01:53AM

Re: fastcgi_cache_key with cookie

zenw December 27, 2011 01:56AM

Re: fastcgi_cache_key with cookie

António P. P. Almeida December 27, 2011 02:36AM

Re: fastcgi_cache_key with cookie

zenw December 27, 2011 02:46AM

Re: fastcgi_cache_key with cookie

zenw December 27, 2011 02:48AM

Re: fastcgi_cache_key with cookie

António P. P. Almeida December 27, 2011 03:02AM

Re: fastcgi_cache_key with cookie

zenw December 27, 2011 03:24AM

Re: fastcgi_cache_key with cookie

António P. P. Almeida December 27, 2011 04:06AM

Re: fastcgi_cache_key with cookie

brianmercer December 27, 2011 12:01PM

Re: fastcgi_cache_key with cookie

António P. P. Almeida December 27, 2011 02:54PM

Re: fastcgi_cache_key with cookie

zenw December 27, 2011 08:15PM

Re: fastcgi_cache_key with cookie

zenw December 27, 2011 08:35PM

Re: fastcgi_cache_key with cookie

brianmercer December 27, 2011 11:15PM

Re: fastcgi_cache_key with cookie

zenw December 27, 2011 11:28PM

Re: fastcgi_cache_key with cookie

António P. P. Almeida December 28, 2011 02:04AM

Re: fastcgi_cache_key with cookie

brianmercer December 28, 2011 08:55AM

Re: fastcgi_cache_key with cookie

António P. P. Almeida December 28, 2011 11:54AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 212
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready