Nginx FastCGI caching

nemke

Member
Did someone managed to successfully and securely configure Nginx FastCGI cache for guest users?

P.S. Is this right forum to ask things like this? Or should I direct questions like this to tickets?
 
Would be also interesting for me. With vb I couldn't achieve this with nginx fastcgi-caching. Varnish works with vb4 for me.
 
You can fastcgi_cache everything, with Nginx. Follow the documentation, is extremely easy. I say this because pasting some configuration values is useless, as the cache needs to be tweaked based on your site needs. Example of my cached site, only for guests with a 10min refresh interval:
https://www.axivo.com/community/

Litespeed with FastCGI is the way to go with xF
Not necessarily, I think is a matter of how comfortable we are with a product. :)
 
Litespeed with FastCGI is the way to go with xF
Don't know about LiteSpeed, but I know with OpenLiteSpeed I never could get the xCache/Memcache to work. Of course it appears that it may have been due to the fact that I was assigned 2GB to Memcached and 1GB to xCache. :p
Also, I am so used to configuring at the text based level I got confused looking at the pretty pictures when setting everything else up. Ended up just going back to nginx - why fix it when it wasn't broke?
 
I managed to make per user cache to work and it looks stable (I tested it shortly for about 30 minutes and then I shut it down).

But now I need to separate it for guest users only, does anyone have idea if there is some cookie or something similar that I can use?
 
Last edited:
You can fastcgi_cache everything, with Nginx. Follow the documentation, is extremely easy. I say this because pasting some configuration values is useless, as the cache needs to be tweaked based on your site needs. Example of my cached site, only for guests with a 10min refresh interval:
https://www.axivo.com/community/


Not necessarily, I think is a matter of how comfortable we are with a product. :)

would post an example configuration??
 
to receive this type of response would not need to have posted ..
I said it many times, the proper way to learn is by reading the documentation. Copy/Paste is not the proper way to deal with Nginx. If you need/want that, you can rely on Google and implement 90% of the guides out there that are just plain wrong. Instead, take the time to read and understand what Nginx cache does. Once you understand, you will agree with my reply.
 
I said it many times, the proper way to learn is by reading the documentation. Copy/Paste is not the proper way to deal with Nginx. If you need/want that, you can rely on Google and implement 90% of the guides out there that are just plain wrong. Instead, take the time to read and understand what Nginx cache does. Once you understand, you will agree with my reply.
Well one valid way of learning is to start by imitation and to get your head around it first. There's nothing wrong with learning by example :)
 
For me, this site is not really fast. How do you chache a xenforo site ONLY for guests?
Try to visit 2 URL's repeatedly by clicking on them repeatedly, instead of doing a page refresh. I block page refreshes with Nginx by allowing only 5 requests/second up to a burst of maximum 30. If you refresh the page, you will start noticing images missing and other things broken on the page until eventually Nginx will show a warning.

As far as the cache for guests, I use a map to filter the cookies for XenForo and Facebook mixed with a conditional into /community location. So basically if a specific cookie is present, the cache will be turned off automatically. You can check this by adding the upstream_cache_status variable into logs to show the cache status of a page (HIT, MISS etc.). Now time to go back to documentation and transpose everything I said into reality. I know you can do it, if you have roadblocks post them here and I will help... but I will NOT do a copy/paste spoon feed. :)
 
Try to visit 2 URL's repeatedly by clicking on them repeatedly, instead of doing a page refresh. I block page refreshes with Nginx by allowing only 5 requests/second up to a burst of maximum 30. If you refresh the page, you will start noticing images missing and other things broken on the page until eventually Nginx will show a warning.

As far as the cache for guests, I use a map to filter the cookies for XenForo and Facebook mixed with a conditional into /community location. So basically if a specific cookie is present, the cache will be turned off automatically. You can check this by adding the upstream_cache_status variable into logs to show the cache status of a page (HIT, MISS etc.). Now time to go back to documentation and transpose everything I said into reality. I know you can do it, if you have roadblocks post them here and I will help... but I will NOT do a copy/paste spoon feed. :)

If I understand you correctly, I should turn caching on unless xf_session or cookie_xf_fbUid is set?

Of course if they are not set, until user visits /login I should hide and ignore this headers?
fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
fastcgi_hide_header Cache-Control;
fastcgi_hide_header Expires;
fastcgi_hide_header Set-Cookie;

One flaw I see here is that when user logs out, cache will be disabled until he closes/opens browser again because xf_session is still set and it's a session cookie.
 
You don't need to ignore the headers, Nginx cache is set by default on GET's. When you login, you submit a POST so it will never be cached... which is the proper approach. You don't that login page cached, as well the registration. When the user logs out, he/she is pushed back to XenForo page with a GET so it is again cached automatically.
 
My fastcgi_cache only works with the headers ignored. If I comment that line out, the cache does not work for "pretty urls" anymore.
 
Back
Top Bottom