1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Nginx FastCGI caching

Discussion in 'Server Configuration and Hosting' started by nemke, Dec 14, 2013.

  1. nemke

    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?
  2. archimedes

    archimedes Member

    Would be also interesting for me. With vb I couldn't achieve this with nginx fastcgi-caching. Varnish works with vb4 for me.
  3. Non Guru

    Non Guru Member

    Me too
  4. Mike Edge

    Mike Edge Formerly Da Bookie Mon

    Litespeed with FastCGI is the way to go with xF
  5. Floren

    Floren Well-Known Member

    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:

    Not necessarily, I think is a matter of how comfortable we are with a product. :)
    SneakyDave likes this.
  6. Tracy Perry

    Tracy Perry Well-Known Member

    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?
  7. nemke

    nemke Member

    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: Dec 17, 2013
    SneakyDave likes this.
  8. FabioCesar

    FabioCesar Member

    would post an example configuration??
  9. Floren

    Floren Well-Known Member

  10. FabioCesar

    FabioCesar Member

    to receive this type of response would not need to have posted ..
  11. Floren

    Floren Well-Known Member

    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.
  12. DRaver

    DRaver Active Member

    For me, this site is not really fast. How do you chache a xenforo site ONLY for guests?
  13. p4guru

    p4guru Well-Known Member

    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 :)
  14. Floren

    Floren Well-Known Member

    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. :)
  15. nemke

    nemke Member

    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.
  16. Floren

    Floren Well-Known Member

    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.
  17. Marcus

    Marcus Well-Known Member

    My fastcgi_cache only works with the headers ignored. If I comment that line out, the cache does not work for "pretty urls" anymore.
  18. Ranma1981

    Ranma1981 Member


    me too I am interested. Someone has some example on how to configure Nginx fastcgi for guest users?
  19. RoldanLT

    RoldanLT Well-Known Member

    Any progress on this?
    I would like to try this also.

Share This Page