Discover Centmin Mod today
Register Now

Xenforo Fastcgi cache configuration for Xenforo?

Discussion in 'Forum software usage' started by Everlind, Jun 17, 2014.

  1. rdan

    rdan Well-Known Member

    5,419
    1,386
    113
    May 25, 2014
    Ratings:
    +2,167
    Local Time:
    6:27 PM
    Mainline
    10.2
    Thanks a lot @hungphutho
    I hope @Floren can also share his thoughts about this.
    Hope :angelic::angelic::angelic:

     
  2. rdan

    rdan Well-Known Member

    5,419
    1,386
    113
    May 25, 2014
    Ratings:
    +2,167
    Local Time:
    6:27 PM
    Mainline
    10.2
    I got this error:
     
  3. rdan

    rdan Well-Known Member

    5,419
    1,386
    113
    May 25, 2014
    Ratings:
    +2,167
    Local Time:
    6:27 PM
    Mainline
    10.2
    @hungphutho
    Any advice on this?
     
  4. rdan

    rdan Well-Known Member

    5,419
    1,386
    113
    May 25, 2014
    Ratings:
    +2,167
    Local Time:
    6:27 PM
    Mainline
    10.2
    I just move this:
    Code:
    fastcgi_cache_path /var/cache/nginx levels=1:2 keys_zone=fastcgicache:10m inactive=10m max_size=100m;
    fastcgi_cache_key $scheme$request_method$host$request_uri;
    fastcgi_cache_lock on;
    fastcgi_cache_use_stale error timeout invalid_header updating http_500;
    fastcgi_cache_valid 5m;
    fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
    on nginx.conf below
    http {


    Works now I think :)
     
  5. hungphutho

    hungphutho Member

    55
    35
    18
    Jun 2, 2014
    Ratings:
    +35
    Local Time:
    5:27 PM
    1.7.2
    Percona 5.6
    fastcgi cache you are using multiple domains ?
     
  6. rdan

    rdan Well-Known Member

    5,419
    1,386
    113
    May 25, 2014
    Ratings:
    +2,167
    Local Time:
    6:27 PM
    Mainline
    10.2
    On the test vps, yes.
     
  7. hungphutho

    hungphutho Member

    55
    35
    18
    Jun 2, 2014
    Ratings:
    +35
    Local Time:
    5:27 PM
    1.7.2
    Percona 5.6
    If you use multiple domains on a server with fastcgi cache, the need to create separate files for each domain php.conf ???

    example .
    domain1.com.conf
    Code:
    fastcgi_cache_path /var/cache/nginx levels=1:2 keys_zone=fastcgicache1:10m inactive=10m max_size=100m;
    fastcgi_cache_key $scheme$request_method$host$request_uri;
    fastcgi_cache_lock on;
    fastcgi_cache_use_stale error timeout invalid_header updating http_500;
    fastcgi_cache_valid 5m;
    fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
    server {
    [ .........]
    include /usr/local/nginx/conf/php1.conf;
    [ .........]
    
    }
    domain2.com.conf

    Code:
    fastcgi_cache_path /var/cache/nginx levels=1:2 keys_zone=fastcgicache2:10m inactive=10m max_size=100m;
    fastcgi_cache_key $scheme$request_method$host$request_uri;
    fastcgi_cache_lock on;
    fastcgi_cache_use_stale error timeout invalid_header updating http_500;
    fastcgi_cache_valid 5m;
    fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
    server {
    [ .........]
    include /usr/local/nginx/conf/php2.conf;
    [ .........]
    }
    
    php1.conf
    Code:
    [ .........]
    fastcgi_cache fastcgicache1;
    fastcgi_cache_bypass $no_cache; # $is_mobile
    fastcgi_no_cache $no_cache; # $is_mobile
    fastcgi_cache_valid  200 302 2m;
    fastcgi_cache_valid  301 1h;
    fastcgi_cache_valid 404 1m;
    fastcgi_cache_valid  any 2m;
    #proxy_cache_min_uses 3; # cached only after 3 occurrences of the same request and held for 2 minute
    #add_header X-Cached $upstream_cache_status;
    php2.conf
    Code:
    [ .........]
    fastcgi_cache fastcgicache2;
    fastcgi_cache_bypass $no_cache; # $is_mobile
    fastcgi_no_cache $no_cache; # $is_mobile
    fastcgi_cache_valid  200 302 2m;
    fastcgi_cache_valid  301 1h;
    fastcgi_cache_valid 404 1m;
    fastcgi_cache_valid  any 2m;
    #proxy_cache_min_uses 3; # cached only after 3 occurrences of the same request and held for 2 minute
    #add_header X-Cached $upstream_cache_status;
     
  8. rdan

    rdan Well-Known Member

    5,419
    1,386
    113
    May 25, 2014
    Ratings:
    +2,167
    Local Time:
    6:27 PM
    Mainline
    10.2
    Just an update, I got it working 99% as far as I tested :D

    My config:
    nginx.conf above
    include /usr/local/nginx/conf/conf.d/*.conf;
    Code:
    ### fastcgi_cache
    ###
    fastcgi_cache_path /var/cache/nginx levels=1:2 keys_zone=phcornercache:1000m inactive=1d max_size=100m;
    fastcgi_cache_key "$scheme$request_method$host$request_uri";
    fastcgi_cache_lock on;
    fastcgi_cache_use_stale error timeout invalid_header updating http_500;
    fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
    ###
    ### fastcgi_cache end
    

    php.conf above }
    Code:
    ### fastcgi_cache 
    ###                
    fastcgi_cache phcornercache;
    fastcgi_cache_bypass $no_cache;
    fastcgi_no_cache $no_cache;
    fastcgi_cache_valid  200 302 15m;
    fastcgi_cache_valid  301 1h;
    fastcgi_cache_valid  404 5m;
    fastcgi_cache_valid  any 15m;
    add_header X-Cached $upstream_cache_status;
    ###  
    ### fastcgi_cache end
    

    Domain conf above location / {
    Code:
    ### fastCgi cache
        set $no_cache 0;
    
        # POST requests should always go to PHP
        if ($request_method = POST) {
            set $no_cache 1;
        }
    
        # Don't use the cache for logged in users
        if ($http_cookie ~* "xf_session_admin|xf_user|xf_user_admin") {
            set $no_cache 1;
        }
    
        # Don't cache uris containing the following segments
        if ($request_uri ~* "(/login/|/register/|/login|/register|/library/|/internal_data/)") {
            set $no_cache 1;
        }
        ### fastCgi end
     
    Last edited: Sep 14, 2014
  9. eva2000

    eva2000 Administrator Staff Member

    50,479
    11,664
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,089
    Local Time:
    8:27 PM
    Nginx 1.25.x
    MariaDB 10.x
    This is on your live forums ?
     
  10. rdan

    rdan Well-Known Member

    5,419
    1,386
    113
    May 25, 2014
    Ratings:
    +2,167
    Local Time:
    6:27 PM
    Mainline
    10.2
    Not yet, just a test VPS.
     
  11. eva2000

    eva2000 Administrator Staff Member

    50,479
    11,664
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,089
    Local Time:
    8:27 PM
    Nginx 1.25.x
    MariaDB 10.x
    look very good there :D (y) :woot:
     
  12. rdan

    rdan Well-Known Member

    5,419
    1,386
    113
    May 25, 2014
    Ratings:
    +2,167
    Local Time:
    6:27 PM
    Mainline
    10.2
    I have read almost 10 articles that tackle fastcgi_cache including the main age at nginx.org Module ngx_http_fastcgi_module

    And strip some of the code by @hungphutho some of it are already the default value and some of he filter are redundant.
    I focus on filtering via cookies.
     
  13. rdan

    rdan Well-Known Member

    5,419
    1,386
    113
    May 25, 2014
    Ratings:
    +2,167
    Local Time:
    6:27 PM
    Mainline
    10.2
    I will apply it on my Live Forum next few minutes :)
     
  14. rdan

    rdan Well-Known Member

    5,419
    1,386
    113
    May 25, 2014
    Ratings:
    +2,167
    Local Time:
    6:27 PM
    Mainline
    10.2
  15. rdan

    rdan Well-Known Member

    5,419
    1,386
    113
    May 25, 2014
    Ratings:
    +2,167
    Local Time:
    6:27 PM
    Mainline
    10.2
    @eva2000 Why not apply it on this forum?
    Lets unite the debugging mode :D
    Applying now on my live forum :D
     
  16. eva2000

    eva2000 Administrator Staff Member

    50,479
    11,664
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,089
    Local Time:
    8:27 PM
    Nginx 1.25.x
    MariaDB 10.x
    You can go first.. I'll watch :LOL::D
     
  17. rdan

    rdan Well-Known Member

    5,419
    1,386
    113
    May 25, 2014
    Ratings:
    +2,167
    Local Time:
    6:27 PM
    Mainline
    10.2
    Already applied on my live forum, hopefully my members will not encounter any issues :D :woot:
     
  18. rdan

    rdan Well-Known Member

    5,419
    1,386
    113
    May 25, 2014
    Ratings:
    +2,167
    Local Time:
    6:27 PM
    Mainline
    10.2
  19. rdan

    rdan Well-Known Member

    5,419
    1,386
    113
    May 25, 2014
    Ratings:
    +2,167
    Local Time:
    6:27 PM
    Mainline
    10.2
    Here's the problem that I don't know how to fix.
    Guest can't change style :/
     
  20. Floren

    Floren Active Member

    148
    77
    28
    Jun 6, 2014
    Ratings:
    +77
    Local Time:
    6:27 AM
    @eva2000, let me know if you implemented this on these forums, so I can never login here. I don't want to have my private information (i.e. conversations) displayed to everyone. Start a conversation on AXIVO and let me know. Thanks. Logging out...