I implemented FastCGI caching on our website and saw big speed improvements. However, the FastCGI cache key does not seem unique enough. If I log in, my name will appear in the header. However, the next user to log in still sees my name in the header, assuming that the cache remains valid.
Is there a way to make the cache key unique to each user? Is it ideal to use a unique identifier from a user of cookies or a PHP session? I tried to execute the answer below, but Nginx could not restart.
Enter the value from the Set-Cookie header in nginx
Please note that my cache code is as follows:
fastcgi_cache_key "$scheme$request_method$host$request_uri";
Update: My thought is that I can parse the HTTP headers sent by Nginx, then I can capture the PHP SESSION identifier and use it. However, I cannot find an example of how to do this anywhere. Right now I have something like this that doesn't work.
http_cookie ~* PHPSESSID=([0-9a-z]+) {
set $ses_id $1;
}
source
share