Xenforo + Fastcgi_cache


I am using the following structure: nginx + php-fpm + xcache
Have a satisfactory outcome, but I would take more server resources only for registered users, my intention is to store the cache for visitors leaving the server under load.

I'm using these settings in nginx:

fastcgi_cache_path /tmp/fastcgicache levels=1:2
keys_zone=MYCACHE2:5m inactive=2h max_size=1g loader_files=1000

fastcgi_cache_key "$scheme$request_method$host$request_uri";
set $no_cache 0;
if ($http_cookie ~* (xf_session_admin|xf_user|xf_user_admin)) {
set $no_cache 1;
fastcgi_cache MYCACHE2;
fastcgi_keep_conn on;
fastcgi_cache_bypass $no_cache;
fastcgi_no_cache $no_cache;
fastcgi_cache_valid 200 301 10m;
fastcgi_cache_valid 302 5m;
fastcgi_cache_valid 404 1m;
fastcgi_cache_use_stale error timeout invalid_header updating http_500;
fastcgi_ignore_headers Cache-Control Expires;
expires epoch;
fastcgi_cache_lock on;
My problem is at login time, even "logged" nginx keeps sending the cache.
Can someone give me a hand?


Well-known member
You forgot to define an except location in your configuration, that's why.
You want to serve the cache ONLY when the users are not logged and flush it every 10min, or else your guests (i.e. Google) will see the same content forever.
Would it be possible to post an example of the configuration it was possible to login?

Maybe you think the cache about 20 minutes, do not intend to keep the cache longer than that ...

Initially tested the varnish, but with nginx had a similar performance ..


Maybe this problem is related to cookie xf_session?
Alternatively, you can set Session.php SearchReferer and isRobot required expiration lifetime and use these value in nginx


Well-known member
Posting a configuration is useless as my setup is not the same as your. The best place for you to learn is Nginx documentation. As helper, you need to define a special cookie, the default Xenforo is not always created. You also need to skip the login location or else you end up mixing user information in cache.