Learn about Centmin Mod LEMP Stack today
Become a Member

Xenforo Fastcgi cache configuration for Xenforo?

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

  1. rdan

    rdan Well-Known Member

    4,547
    1,089
    113
    May 25, 2014
    Ratings:
    +1,590
    Local Time:
    12:51 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

    4,547
    1,089
    113
    May 25, 2014
    Ratings:
    +1,590
    Local Time:
    12:51 PM
    Mainline
    10.2
    I got this error:
     
  3. rdan

    rdan Well-Known Member

    4,547
    1,089
    113
    May 25, 2014
    Ratings:
    +1,590
    Local Time:
    12:51 PM
    Mainline
    10.2
    @hungphutho
    Any advice on this?
     
  4. rdan

    rdan Well-Known Member

    4,547
    1,089
    113
    May 25, 2014
    Ratings:
    +1,590
    Local Time:
    12:51 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:
    11:51 AM
    1.7.2
    Percona 5.6
    fastcgi cache you are using multiple domains ?
     
  6. rdan

    rdan Well-Known Member

    4,547
    1,089
    113
    May 25, 2014
    Ratings:
    +1,590
    Local Time:
    12:51 PM
    Mainline
    10.2
    On the test vps, yes.
     
  7. hungphutho

    hungphutho Member

    55
    35
    18
    Jun 2, 2014
    Ratings:
    +35
    Local Time:
    11:51 AM
    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;
     
    • Like Like x 2
  8. rdan

    rdan Well-Known Member

    4,547
    1,089
    113
    May 25, 2014
    Ratings:
    +1,590
    Local Time:
    12:51 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
    • Like Like x 2
  9. eva2000

    eva2000 Administrator Staff Member

    40,342
    8,931
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +13,755
    Local Time:
    2:51 PM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    This is on your live forums ?
     
  10. rdan

    rdan Well-Known Member

    4,547
    1,089
    113
    May 25, 2014
    Ratings:
    +1,590
    Local Time:
    12:51 PM
    Mainline
    10.2
    Not yet, just a test VPS.
     
  11. eva2000

    eva2000 Administrator Staff Member

    40,342
    8,931
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +13,755
    Local Time:
    2:51 PM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    look very good there :D (y) :woot:
     
    • Like Like x 1
  12. rdan

    rdan Well-Known Member

    4,547
    1,089
    113
    May 25, 2014
    Ratings:
    +1,590
    Local Time:
    12:51 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.
     
    • Like Like x 1
  13. rdan

    rdan Well-Known Member

    4,547
    1,089
    113
    May 25, 2014
    Ratings:
    +1,590
    Local Time:
    12:51 PM
    Mainline
    10.2
    I will apply it on my Live Forum next few minutes :)
     
    • Like Like x 1
  14. rdan

    rdan Well-Known Member

    4,547
    1,089
    113
    May 25, 2014
    Ratings:
    +1,590
    Local Time:
    12:51 PM
    Mainline
    10.2
  15. rdan

    rdan Well-Known Member

    4,547
    1,089
    113
    May 25, 2014
    Ratings:
    +1,590
    Local Time:
    12:51 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

    40,342
    8,931
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +13,755
    Local Time:
    2:51 PM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    You can go first.. I'll watch :LOL::D
     
    • Like Like x 1
  17. rdan

    rdan Well-Known Member

    4,547
    1,089
    113
    May 25, 2014
    Ratings:
    +1,590
    Local Time:
    12:51 PM
    Mainline
    10.2
    Already applied on my live forum, hopefully my members will not encounter any issues :D :woot:
     
    • Like Like x 1
  18. rdan

    rdan Well-Known Member

    4,547
    1,089
    113
    May 25, 2014
    Ratings:
    +1,590
    Local Time:
    12:51 PM
    Mainline
    10.2
    • Like Like x 1
  19. rdan

    rdan Well-Known Member

    4,547
    1,089
    113
    May 25, 2014
    Ratings:
    +1,590
    Local Time:
    12:51 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:
    12:51 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...
     
..