XenForo Forum with Nginx fastcgi_cache full page guest caching

XenForo Forum with Nginx fastcgi_cache full page guest caching

Amin Sabet

Well-known member
Here's the one I was most interested in, fastcgi_cache enabled, ngx_pagespeed on or off:

Time to First Byte is shorter with ngx_pagespeed off: 236ms vs 285ms

Time to Start Render is shorter with ngx_pagespeed off: 1590ms vs 1599ms

Doc Complete Time is shorter with ngx_pagespeed on: 9459ms vs 13188ms

Image Total Bytes is lower with ngx_pagespeed on: 1552551 vs 3577074

Visually Complete is shorter with ngx_pagespeed on: 8976ms vs 12496ms

DOM Content Ready Start is shorter with ngx_pagespeed on: 4875ms vs 7710ms

Speed Index is lower (better) with ngx_pagespeed on: 2011 vs 2159
 

Gene Steinberg

Well-known member
Briefly, I had a Plesk server with Apache and nginx. I used PHP-FPM and PHP 7.0.x for maximum performance, and it was pretty good. Currently I have a cPanel server with PHO-FPM and PHP 7.0.x and it's noticeably faster. Alas, the nginx add-ons for cPanel are all buggy (and apparently break AWStats).
 

eva2000

Well-known member
Here's the one I was most interested in, fastcgi_cache enabled, ngx_pagespeed on or off:

Time to First Byte is shorter with ngx_pagespeed off: 236ms vs 285ms

Time to Start Render is shorter with ngx_pagespeed off: 1590ms vs 1599ms

Doc Complete Time is shorter with ngx_pagespeed on: 9459ms vs 13188ms

Image Total Bytes is lower with ngx_pagespeed on: 1552551 vs 3577074

Visually Complete is shorter with ngx_pagespeed on: 8976ms vs 12496ms

DOM Content Ready Start is shorter with ngx_pagespeed on: 4875ms vs 7710ms

Speed Index is lower (better) with ngx_pagespeed on: 2011 vs 2159
this is the one that i am most focused on doc complete, visually complete and dom content ready start and speedindex times but as expected fastcgi_cache will improve things as it's in memory and TTFB is a bit slower with ngx_pagespeed as it has to process and optimise assets for that faster visually complete time.
 

eva2000

Well-known member
None of my tests showed much of an advantage of bd cache pages for guests compared with fastcgi_cache or even no page cache for guests at all. It's possible I implemented bd cache pages for guests incorrectly.
what is bd cache ttl cache time set at ?
 

Amin Sabet

Well-known member
Here's a test of different image optimization methods. I left Cloudflare enabled in both cases but in one set of 3 runs I had Polish turned off and ngx_pagespeed turned on, while in the other set of runs I had Polish (lossy with webp) turned on and ngx_pagespeed turned off. In both cases I had fastcgi_cache enabled.

Time to First Byte is shorter with Polish: 218ms vs 267ms

Time to Start Render is shorter with Polish: 1297ms vs 1486ms

Doc Complete Time is shorter with Pagespeed: 9813ms vs 10277
Image Total Bytes is lower with Pagespeed: 2123470 vs 2461384

Visually Complete is shorter with Pagespeed: 9604ms vs 9618ms

DOM Content Ready Start is shorter with Pagespeed: 5479ms vs 5702ms

Speed Index is lower (better) with Polish: 1673 vs 1827

I left Pagespeed image compression quality settings at default. I should also note that I don't use Pagespeed for css or js, only for images, so YMMV.

From those data, Polish looks like the winner to me. However, I think ngx_pagespeed does a much better job optimizing images for mobile than Cloudflare Mirage does, and I've noticed some occasional weirdness with Cloudflare image optimization (images not showing) that I never get with ngx_pagespeed, so the decision isn't an easy one. For now I am going with Cloudflare image optimization (Polish but not Mirage) and have disabled ngx_pagespeed.
 
Last edited:

rdn

Well-known member
RoldanLT updated XenForo Forum with Nginx fastcgi_cache full page guest caching with a new update entry:

Move several config under location context.

Move several config under location context from http context.
fastcgi_cache_key $scheme$request_method$host$request_uri$mobile_request;
fastcgi_cache_use_stale error timeout invalid_header updating http_500;
fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
To be sure only specific sites/location has caching enabled.
Read the rest of this update entry...
 

Solidus

Well-known member
Here's a test of different image optimization methods. I left Cloudflare enabled in both cases but in one set of 3 runs I had Polish turned off and ngx_pagespeed turned on, while in the other set of runs I had Polish (lossy with webp) turned on and ngx_pagespeed turned off. In both cases I had fastcgi_cache enabled.

Time to First Byte is shorter with Polish: 218ms vs 267ms

Time to Start Render is shorter with Polish: 1297ms vs 1486ms

Doc Complete Time is shorter with Pagespeed: 9813ms vs 10277
Image Total Bytes is lower with Pagespeed: 2123470 vs 2461384

Visually Complete is shorter with Pagespeed: 9604ms vs 9618ms

DOM Content Ready Start is shorter with Pagespeed: 5479ms vs 5702ms

Speed Index is lower (better) with Polish: 1673 vs 1827

I left Pagespeed image compression quality settings at default. I should also note that I don't use Pagespeed for css or js, only for images, so YMMV.

From those data, Polish looks like the winner to me. However, I think ngx_pagespeed does a much better job optimizing images for mobile than Cloudflare Mirage does, and I've noticed some occasional weirdness with Cloudflare image optimization (images not showing) that I never get with ngx_pagespeed, so the decision isn't an easy one. For now I am going with Cloudflare image optimization (Polish but not Mirage) and have disabled ngx_pagespeed.
Have you also enabled WebP?
https://blog.cloudflare.com/a-very-webp-new-year-from-cloudflare/
 

Sunka

Well-known member
@RoldanLT, before I install this addon, one question
In my template helper_login_form and login_bar_form I add checked="checked" so remember me option is by default checked.
Code:
Original:
<label class="rememberPassword"><input type="checkbox" name="remember" value="1" id="ctrl_pageLogin_remember" tabindex="3" /> {xen:phrase stay_logged_in}</label>

Mine:
<label class="rememberPassword"><input type="checkbox" name="remember" value="1" id="ctrl_pageLogin_remember" tabindex="3" checked="checked" /> {xen:phrase stay_logged_in}</label>
Any solution to add that to your customization?
Something like:
Code:
<input type="hidden" name="remember" value="1" checked="checked" />
Or must be without that:
Code:
<input type="hidden" name="remember" value="1" />
 

rdn

Well-known member
For those forum that don't have distinction for Mobile and Desktop viewers, you can minimize the code into this.

nginx.conf
Code:
### Start 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;
### End FastCGI Cache ################
Changes: https://www.diffchecker.com/bj8EOODX


location ~ [^/]\.php(/|$) {
Code:
### fastcgi_cache start ###
fastcgi_cache_methods GET;
fastcgi_cache_key       $scheme$request_method$host$request_uri;
fastcgi_cache_use_stale error timeout invalid_header updating http_500;
fastcgi_ignore_headers  Cache-Control Expires Set-Cookie;
fastcgi_cache           fastcgicache;
fastcgi_no_cache        $nocachecookie $nocacheuri;
fastcgi_cache_bypass    $nocachecookie $nocacheuri;
fastcgi_cache_valid     200 301 302 303 304 404 15m;
add_header X-Cache-Status   $upstream_cache_status;
### fastcgi_cache end ###
Changes: https://www.diffchecker.com/knRK1OqM
 

rdn

Well-known member
Centmin Mod forum is slowed down by ads + mutiple web analytics trackers for GA + piwik heh
I also have:
  • Google Analytics
  • Google Adsense
  • Google Matched Content
  • Amazon Ads
  • ClickIO Ads

:D much faster without ads.
 

eva2000

Well-known member
yeah ads & trackers accounts for 60% of my page load time heh

curious phcorner vs centminmod forums dulles cable 5 webpagetest over 3 runs
  • phcorner with OVH Canada ? = cloudflare > fastcgi_cache > redis cache via xon > xenforo running Centmin Mod LEMP stack
  • cmm with Fremont. CA Linode = sucuri cloudproxy > ngx_pagespeed > db optimise redis cache > xenforo running Centmin Mod LEMP stack
upload_2016-12-31_17-44-32.png

upload_2016-12-31_17-42-7.png

upload_2016-12-31_17-42-49.png

upload_2016-12-31_17-43-20.png

cmm at webpagetest san jose cable 5 region closer to Fremont, CA

upload_2016-12-31_17-50-5.png

upload_2016-12-31_17-49-37.png

upload_2016-12-31_17-51-2.png

either way fast is fast when using the right web stack = Centmin Mod LEMP stack :)
 
Last edited:

Amin Sabet

Well-known member
Going back and forth between the phcorner home page and any of those "most replied" popular topics, the page load is nearly instant. I was assuming that was due to fastcgi_cachi, but it even seems to be the case when I am logged in as a member (y).
 
Last edited:
  • Like
Reactions: rdn

eva2000

Well-known member
Going back and forth between the phcorner home page and any of those "most replied" popular topics, the page load is nearly instant. I was assuming that was due to fastcgi_cachi, but it even seems to be the case when I am logged in as a member (y).
could be fastcgi_cache helping or more likely a combination of cloudflare cdn edge cache + browser caching + fastcgi_cache helps too as if you test with browser cache disabled the page doesn't load as fast
 
Top