Join the community today
Become a Member

Nginx Nginx PageSpeed Domains Large Waiting Time.

Discussion in 'Install & Upgrades or Pre-Install Questions' started by Varun, Apr 13, 2018.

  1. Varun

    Varun Premium Member Premium Member

    36
    2
    8
    Apr 6, 2018
    India, Tamil Nadu, Chennai
    Ratings:
    +3
    Local Time:
    9:25 PM
    1.13.11
    I have installed Centminmod latest beta and wordpress + woocommerce site in a server with only 1 account

    While loading it takes a long time to load the website so i checked the timing and found there a big block of waiting time

    [​IMG]

    I never encountered this kind of issue with Apache. before. is this related to nginx and DNS TTL for now i have set the DNS TTL for 100sec
     
  2. eva2000

    eva2000 Administrator Staff Member

    36,387
    7,992
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +12,304
    Local Time:
    1:55 AM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    There's no DNS resolution timings shown there at all ? Is this HTTPS SSL certificate based site with letsencrypt SSL ?

    Might want to try testing site in webpagetest.org using WebPerf - PageSpeed - How to use webpagetest.org for page load speed testing

    Which form of wordpress caching you selected ? keycdn cache enabler, redis nginx level caching or wp super cache ? Try with ngx_pagespeed disable too.

    Centmin Mod values security and puts additional measures in place so that end users are also mindful of security. So in your case, make sure you are not running into any 403 permission denied messages for wordpress related php requests.

    If you used centmin.sh menu option 22 auto installer Wordpress Nginx Auto Installer, the default wpsecure conf file at /usr/local/nginx/conf/wpincludes/${vhostname}/wpsecure_${vhostname}.conf where vhostname is your domain name, blocks php scripts from executing in wp-content for security

    Below links you can see examples of setting up specific wordpress location matches to punch a hole in the wpsecure blocking to whitelist specific php files that need to be able to run.
    If on Centmin Mod 123.09beta01, you may have ran into the new tools/autoprotect.sh cronjob feature outlined at Beta Branch - autoprotect.sh - apache .htaccess check & migration to nginx deny all | Centmin Mod Community You uploaded scripts may have .htaccess deny from all type files in their directories which may need bypassing autoprotect. It's a security feature that no other nginx based stack has as far as I know :)

    So instead, all .htaccess 'deny from all' detected directories now get auto generated Nginx equivalent location match and deny all setups except if you want to manually bypass the directory from auto protection via a .autoprotect-bypass file - details below here.

    You can read a few threads below on how autoprotect.sh may have caught some folks web apps falsely and the workarounds or improvements made to autoprotect.sh with the help of users feedback and troubleshooting.
    So check your nginx access and error logs for clues in /home/nginx/domains/yourdomain/logs directory. Nginx access logs are buffered so may need an nginx restart to flush the buffer to access logs.
     
  3. Varun

    Varun Premium Member Premium Member

    36
    2
    8
    Apr 6, 2018
    India, Tamil Nadu, Chennai
    Ratings:
    +3
    Local Time:
    9:25 PM
    1.13.11
    Since i have moved my wordpress from another site.
    I haven't used centminmod wp install i just restored my wordpress from old server.
     
  4. Varun

    Varun Premium Member Premium Member

    36
    2
    8
    Apr 6, 2018
    India, Tamil Nadu, Chennai
    Ratings:
    +3
    Local Time:
    9:25 PM
    1.13.11
    Hi,

    With the below config i was successfully able to bring it down from 6000 ms to 3000 - 4000 ms
    max of 5000ms which only if load it first time. and after that its around 3000 - 4000 MS still not sure whats wrong

    here is the config files

    Non SSL :
    Code (Text):
    server {
        server_name omgeg.com www.omgeg.com;
    
        access_log /home/nginx/domains/omgeg.com/log/access.log combined buffer=256k flush=5m;
        error_log /home/nginx/domains/omgeg.com/log/error.log;
    
        #include /usr/local/nginx/conf/autoprotect/omgeg.com/autoprotect-omgeg.com.conf;
    
        root /home/nginx/domains/omgeg.com/public;
    
        include /usr/local/nginx/conf/503include-main.conf;
        include /usr/local/nginx/conf/wpincludes/omgeg.com/wpcacheenabler_omgeg.com.conf;
    
        location / {
            include /usr/local/nginx/conf/503include-only.conf;
            # for wp cache enabler plugin
            try_files $cache_enabler_uri $uri $uri/ $custom_subdir/index.php?$args;
        }
    
        location ~* /(wp-login\.php) {
            limit_req zone=xwplogin burst=1 nodelay;
            include /usr/local/nginx/conf/php-wpsc.conf;
        }
    
        location ~* /(xmlrpc\.php) {
            limit_req zone=xwprpc burst=45 nodelay;
            include /usr/local/nginx/conf/php-wpsc.conf;
        }
    
        location ~* /wp-admin/(load-scripts\.php) {
            limit_req zone=xwprpc burst=5 nodelay;
            include /usr/local/nginx/conf/php-wpsc.conf;
        }
    
        location ~* /wp-admin/(load-styles\.php) {
            limit_req zone=xwprpc burst=5 nodelay;
            include /usr/local/nginx/conf/php-wpsc.conf;
        }
    
        #include /usr/local/nginx/conf/wpincludes/omgeg.com/wpsecure_omgeg.com.conf;
        include /usr/local/nginx/conf/php-wpsc.conf;
        #include /usr/local/nginx/conf/pre-staticfiles-local-omgeg.com.conf;
        include /usr/local/nginx/conf/pre-staticfiles-global.conf;
        include /usr/local/nginx/conf/staticfiles.conf;
        include /usr/local/nginx/conf/drop.conf;
        include /usr/local/nginx/conf/vts_server.conf;
    }
    
    




    SSL Config :

    Code (Text):
    server {
        listen 443 ssl http2;
        server_name omgeg.com www.omgeg.com;
    
        #ssl_dhparam /usr/local/nginx/conf/ssl/omgeg.com/dhparam.pem;
        ssl_certificate      /usr/local/nginx/conf/ssl/omgeg.com/omgeg.crt;
        ssl_certificate_key  /usr/local/nginx/conf/ssl/omgeg.com/omgeg.key;
        include /usr/local/nginx/conf/ssl_include.conf;
    
        http2_max_field_size 16k;
        http2_max_header_size 32k;
    
        # mozilla recommended
        ssl_ciphers ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS;
        ssl_prefer_server_ciphers   on;
        ssl_buffer_size 1369;
        ssl_session_tickets on;
    
        access_log /home/nginx/domains/omgeg.com/log/access.log combined buffer=256k flush=5m;
        error_log /home/nginx/domains/omgeg.com/log/error.log;
    
        #include /usr/local/nginx/conf/autoprotect/omgeg.com/autoprotect-omgeg.com.conf;
       
        root /home/nginx/domains/omgeg.com/public;
        include /usr/local/nginx/conf/503include-main.conf;
    
        include /usr/local/nginx/conf/wpincludes/omgeg.com/wpcacheenabler_omgeg.com.conf;
    
        location / {
            include /usr/local/nginx/conf/503include-only.conf;
            # for wp cache enabler plugin
            try_files $cache_enabler_uri $uri $uri/ $custom_subdir/index.php?$args;  
        }
    
        location ~* /(wp-login\.php) {
            limit_req zone=xwplogin burst=1 nodelay;
            auth_basic "Private";
            include /usr/local/nginx/conf/php-wpsc.conf;
        }
    
        location ~* /(xmlrpc\.php) {
            limit_req zone=xwprpc burst=45 nodelay;
            include /usr/local/nginx/conf/php-wpsc.conf;
        }
    
        location ~* /wp-admin/(load-scripts\.php) {
            limit_req zone=xwprpc burst=5 nodelay;
            include /usr/local/nginx/conf/php-wpsc.conf;
        }
    
        location ~* /wp-admin/(load-styles\.php) {
            limit_req zone=xwprpc burst=5 nodelay;
            include /usr/local/nginx/conf/php-wpsc.conf;
        }
    
        #include /usr/local/nginx/conf/wpincludes/omgeg.com/wpsecure_omgeg.com.conf;
        include /usr/local/nginx/conf/php-wpsc.conf;
    
        # https://community.centminmod.com/posts/18828/
        #include /usr/local/nginx/conf/php-rediscache.conf;
        #include /usr/local/nginx/conf/pre-staticfiles-local-omgeg.com.conf;
        include /usr/local/nginx/conf/pre-staticfiles-global.conf;
        include /usr/local/nginx/conf/staticfiles.conf;
        include /usr/local/nginx/conf/drop.conf;
        #include /usr/local/nginx/conf/errorpage.conf;
        include /usr/local/nginx/conf/vts_server.conf;
    }
    
    
     
  5. eva2000

    eva2000 Administrator Staff Member

    36,387
    7,992
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +12,304
    Local Time:
    1:55 AM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    These config files generated through centmin.sh menu option 22 wordpress run ?

    as you have wordpress installed in web root and not subdirectory the try_files should be changed from
    Code (Text):
    try_files $cache_enabler_uri $uri $uri/ $custom_subdir/index.php?$args;
    

    to
    Code (Text):
    try_files $cache_enabler_uri $uri $uri/ /index.php?$args;
    

    what's contents of /usr/local/nginx/conf/wpincludes/omgeg.com/wpcacheenabler_omgeg.com.conf ?
    Code (Text):
    cat /usr/local/nginx/conf/wpincludes/omgeg.com/wpcacheenabler_omgeg.com.conf
    

    also confirm if all the connection and rate limiting settings are set in nginx.conf by posting output of this command
    Code (Text):
    grep -n xwp /usr/local/nginx/conf/nginx.conf
    

    Still would want to try testing site in webpagetest.org using WebPerf - PageSpeed - How to use webpagetest.org for page load speed testing and sharing the results link
     
  6. Varun

    Varun Premium Member Premium Member

    36
    2
    8
    Apr 6, 2018
    India, Tamil Nadu, Chennai
    Ratings:
    +3
    Local Time:
    9:25 PM
    1.13.11
    Contents of /usr/local/nginx/conf/wpincludes/omgeg.com/wpcacheenabler_omgeg.com.conf

    Code (Text):
    # Block nginx-help log from public viewing
    location ~* /wp-content/uploads/nginx-helper/ { deny all; }
    
    set $cache_uri $request_uri;
    
    # exclude mobile devices from redis caching
    if ($cmwpcache_device = mobile) { set $cache_uri 'nullcache'; }
    
    # bypass cache if POST requests or URLs with a query string
    if ($request_method = POST) {
        set $cache_uri 'nullcache';
    }
    if ($query_string != "") {
        set $cache_uri 'nullcache';
    }
    
    # bypass cache if URLs containing the following strings
    if ($request_uri ~* "(\?add-to-cart=|/cart/|/my-account/|/checkout/|/shop/checkout/|/store/checkout/|/customer-dashboard/|/addons/|/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php|wp-.*.php|/feed/|index.php|wp-comments-popup.php|wp-links-opml.php|wp-locations.php|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") {
        set $cache_uri 'nullcache';
    }
    
    # bypass cache if the cookies containing the following strings
    if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_logged_in|edd_items_in_cart|woocommerce_items_in_cart|woocommerce_cart_hash|woocommerce_recently_viewed|wc_session_cookie_HASH|wp_woocommerce_session_|wptouch_switch_toogle") {
        set $cache_uri 'nullcache';
    }
    
    # bypass cache for woocommerce
    if ($arg_add-to-cart != "") {
        set $cache_uri 'nullcache';
    }
    
    ## bypass cache for empty woocommerce carts
    #if ($cookie_woocommerce_items_in_cart != "0") {
    #  set $cache_uri 'nullcache';
    #}
    
    # custom sub directory e.g. /blog
    set $custom_subdir '';
    
    # default html file
    set $cache_enabler_uri '${custom_subdir}/wp-content/cache/cache-enabler/${http_host}${cache_uri}index.html';
    
    # webp html file
    if ($http_accept ~* "image/webp") {
        set $cache_enabler_uri '${custom_subdir}/wp-content/cache/cache-enabler/${http_host}${cache_uri}index-webp.html';
    }
    



    Rating Limit Details.
    Code (Text):
    27:limit_req_zone $binary_remote_addr zone=xwprpc:10m rate=30r/s;
    35:limit_req_zone $binary_remote_addr zone=xwplogin:16m rate=40r/m;
    36:#limit_conn_zone $binary_remote_addr zone=xwpconlimit:16m;
    



    As of now i am using gtmetrix.com to test.
     
  7. eva2000

    eva2000 Administrator Staff Member

    36,387
    7,992
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +12,304
    Local Time:
    1:55 AM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    webpagetest.org is more accurate especially due to having more geographic locations to test from and provides more metrics to investigate issues
     
  8. Varun

    Varun Premium Member Premium Member

    36
    2
    8
    Apr 6, 2018
    India, Tamil Nadu, Chennai
    Ratings:
    +3
    Local Time:
    9:25 PM
    1.13.11
    Hi.

    I had issue opening forums after my last post.

    for now i have installed WP Super Cache and now its bit better.

    I have no idea on how to use the site test link which you said.
     
  9. eva2000

    eva2000 Administrator Staff Member

    36,387
    7,992
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +12,304
    Local Time:
    1:55 AM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    Centmin Mod is provide as is, so short of scripted related bugs or issues, any further optimisation to the web stack components - nginx, php-fpm, mariadb mysql, csf firewall etc or web app specific configurations are left to the Centmin Mod user to deal with - including page load speed. So I do not provide any free support for such. You're best bet is to learn how to use webpagetest.org as it's the first thing to do for page load issues to rule out frontend issues first. Just play around with webpagetest.org - it can get addictive :)

    However, Centmin Mod users are free to help each other out and ask questions or give answers on this community forum. My hopes are that this community forum evolves so that more veteran long time Centmin Mod users help new Centmin Mod users out :)

    Definitely invest in the time to learn how to use webpagetest.org from above linked how to guide as it's the best tool and should be your go to for page load speed optimisation ;)

    I'll give you a few hints for your page
    1. too large page load size at 2800KB = 2.8MB nearly ! Should keep page size below 500-1000KB if possible.
    2. too many http requests/assets on page at 169 requests
    3. too many images and large js,css requests some css files are individually larger than 400KB !
    4. you Amazon AWS Cloudfront CDN is misconfigured for HTTPS HTTP/1.1 instead of HTTPS HTTP/2 and also gzip compression is disabled for css & js files instead of enabled. So you're serially loading via HTTPS HTTP/1.1 very large uncompressed css and js files with many of them instead of concurrently loading via HTTPS HTTP/2 compressed gzip assets. Amazon AWS Cloudfront CDN has supported HTTPS HTTP/2 protocol since 2016 Amazon CloudFront now supports HTTP/2
    Example for webpagetest.ogr in Dulles, VA US East Coast for Chrome browser with Cable 5Mbps speeds - actual decent times for 2.8MB page size but on slower ISP connections and mobile 3G would still be very very slow to load for 2.8MB

    upload_2018-4-14_19-44-3.png

    76 images, 51 js and 27 css on index alone !

    upload_2018-4-14_19-45-16.png

    Amazon AWS Cloudfront misconfigurations for css files set to HTTPS HTTP/1.1 with gzip compression disabled

    upload_2018-4-14_19-59-4.png

    upload_2018-4-14_19-54-42.png

    so learn WebPerf - PageSpeed - How to use webpagetest.org for page load speed testing ;)
     
    • Informative Informative x 1
..