XenForo Forum with Nginx fastcgi_cache full page guest caching

Status
Not open for further replies.
I'll use the minimal config guide here: https://xenforo.com/community/threa...-full-page-guest-caching.110806/#post-1025390

Minimal Config :).

nginx.conf
Add below http { block
Code:
### FastCGI Cache ################
map $http_cookie $nocachecookie {
     default                   0;
    ~xf_logged_in              1;
}

fastcgi_cache_path              /tmp/nginx_fastcgi_cache levels=1:2 keys_zone=fastcgicache:200m inactive=30m;
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 ################

Create new file on /usr/local/nginx/conf/, lets name it php_fastcgi_cache.conf
Copy contents from /usr/local/nginx/conf/php.conf to the newly created conf file php_fastcgi_cache.conf.

On php_fastcgi_cache.conf ad above/before the last line }.
Code:
### fastcgi_cache ###
fastcgi_cache           fastcgicache;
fastcgi_cache_bypass    $nocachecookie;
fastcgi_no_cache        $nocachecookie;
fastcgi_cache_valid     5m;
add_header X-Cache      $upstream_cache_status;
### fastcgi_cache end ###

Edit your XenForo Domain Config at /usr/local/nginx/conf/conf.d/yourdomain.com.conf.
Replace every instance of php.conf with php_fastcgi_cache.conf.

Run nprestart.

Done :)

I think I followed the directions exactly but nginx failed to restart with following error:

Code:
[root@server ~]# nginx -t
nginx: [emerg] "map_hash_bucket_size" directive is duplicate in /usr/local/nginx/conf/nginx.conf:37
nginx: configuration file /usr/local/nginx/conf/nginx.conf test failed
 
That was my issue! Once I moved it to nginx.conf below map_hash_bucket_size directive, it works great. I probably can put the other part into php.conf per the OP instead of php_fastcgi_cache.conf now that that error isn't happening. Thank you, again, @RoldanLT !
 
Optional, to have xf_user cookie on every Login Members.

Modify template helper_login_form and login_bar_form.
Replace:
Code:
<label class="rememberPassword"><input type="checkbox" name="remember" value="1" id="ctrl_pageLogin_remember" tabindex="3" /> {xen:phrase stay_logged_in}</label>
With this:
Code:
<input type="hidden" name="remember" checked="checked" value="1" />
Benefits?
Same as Varnish and LiteSpeed Full Page Cache :).
 
Can you give me on Convo your forum url, test username and password?
You must have missed something :/
 
Optional, to have xf_user cookie on every Login Members.

Modify template helper_login_form and login_bar_form.
Replace:

Is this part needed to prevent members from logging in as one another? My templates don't have the exact part you referenced.
 
Is this part needed to prevent members from logging in as one another? My templates don't have the exact part you referenced.
It's optional but adds more prevention for the issue you encounter.
And please change your nginx code to this:
Code:
### FastCGI Cache ################
map $http_cookie $nocachecookie {
     default                   0;
    ~xf_fbUid                  1;
    ~xf_user                   1;
    ~xf_logged_in              1;
}
    
map $request_uri $nocacheuri {
       default              0;
    ~^/register             1;
    ~^/login                1;
    ~^/validate-field       1;
    ~^/captcha              1;
    ~^/lost-password        1;
    ~^/two-step             1;
}

fastcgi_cache_path              /tmp/nginx_fastcgi_cache levels=1:2 keys_zone=fastcgicache:200m inactive=30m;
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 ################
 
Then on php.conf, change to this code.
Code:
### fastcgi_cache ###
fastcgi_cache           fastcgicache;
fastcgi_cache_bypass    $nocachecookie $nocacheuri;
fastcgi_no_cache        $nocachecookie $nocacheuri;
fastcgi_cache_valid     200 202 302 404 403 5m;
fastcgi_cache_valid     301 1h;
fastcgi_cache_valid     any 1m;
add_header X-Cache      $upstream_cache_status;
### fastcgi_cache end ###

Basically please follow my full guide. https://xenforo.com/community/threa...fastcgi_cache-full-page-guest-caching.110806/
 
Status
Not open for further replies.
Top Bottom