fastcgi cache how-to cache for logged-in users and make it custom for each user

António P. P. Almeida appa at perusio.net
Wed Sep 19 16:55:16 UTC 2012


On 19 Set 2012 18h07 CEST, nginx-forum at nginx.us wrote:

> António P. P. Almeida Wrote:
> -------------------------------------------------------
>> On 19 Set 2012 17h04 CEST, nginx-forum at nginx.us wrote:
>>
>>> Hello,
>>>
>>> Currently I'm doing cache using fastcgi_cache for non-logged-in
>>> users, and using ( if + fastcgi_no_cache + fastcgi_cache_bypass )
>>> to pass logged-in users directly to backend which is PHP-FPM.
>>>
>>> this work good enough, but when PHP-FPM start hitting 500+ req/s
>>> the slow/load start.
>>>
>>> So what i'm thinking about is to create a cache for logged-in
>>> users and each user has it's own cached files, is that possible?
>>> if yes can you please provide me some tips about that. I've
>>> goggled a lot but nothing help with that.
>>
>> Use the session ID as part of the cache key. I have a drupal config
>> that uses that:
>>
>> https://github.com/perusio/drupal-with-nginx/blob/master/map_cache.con
>> f

> Woow, It's very useful tip,
>
> Could you illustrate this in details .? , Also Does it need to
> change the way php cms run his own cookies .?

No I don't think so. What may have to change is the regex in the map
directive that captures the session ID. It depends on how is
generated.

You just use something like that and then set the cache key:

## The cache key.
fastcgi_cache_key $cache_uid@$host$request_uri;

--- appa



More information about the nginx mailing list